Get Free Trial
Get Free Trial

Ho can i add caption to the column names and nor showing up all the coulmns by default for the end user.

Answered
Kumar asked on November 6, 2019

Hi Team,
Currently, I get ‘data’ to be shown on flexmonster grid as a json response, as below:

  1. ColumnA2015-01-01T00:00:00Z
  2. ColumnB: XYZ
  3. ColumnC: 1234
  4. ColumnD: AB

I have the ‘slice’ as below:
{
“rows”: [
{ “uniqueName”: “ColumnA“, “caption”:”Column A” },
{ “uniqueName”: “ColumnB“,”caption”:”Column B” }
],
“expands”: { “expandAll”: true }
}
Now in the grid, I am able to view data for the 2 columns. ‘Column A’ and ‘Column B’ (with spaces)are shown up on the grid by default and ‘ColumnC’ and ‘ColumnD’ are unchecked column fields in the grid, and the user has to manually include these two columns to view all 4 columns.
 
Issue 1- How can I have caption for all the JSON keys in the data.
     Any solution other than, having to include all the columns in the slice ‘rows:[]’ object for all the individual reports. As I do have a number of reports with varying numbers of columns returned in the json data.
Is there any way I can have a common .json file, with a list of all the columns(as keys) and corresponding caption(as value) and show values form this json file as the column names for the grid data.
 
Issue 2- Including the columns in the rows:[] object.
     All the columns in the rows[] are displayed in the grid by default. How do I selectively show up the columns in the grid?
In the above example, I get to see Column A and Column B in the grid by default. I want only column A to be displayed and then check/uncheck the other columns from the fields toolbar menu.
 
Thanks in advance!!!

1 answer

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster November 6, 2019

Hello, Kumar,
 
Thank you for reaching out to us.
 

  1. You can simply set desired captions displayed using the mapping key which is a property of dataSource object. The mapping value has to have the following structure:
    {
    "ColumnA": { caption: "Column A" },
    "ColumnB": { caption: "Column B" }
    }


    Please note, that in case of using mapping datatype has to be set within the object presented above.

    Please, find out an example by following the link below: https://jsfiddle.net/flexmonster/n54z1cf0/.

  2. The rows array is used to set fields you want to be opened by default. If you want to leave the specific field hidden don’t include it into the rows array.

 
We sure hope it helps.
Please, let us know if the solution works for you.
 
Feel free to contact us in case of additional questions.
 
Kind regards,
Illia

Please login or Register to Submit Answer