Hi there,
I have an array with the list of column names, that needs to be displayed in the grid.
So, while initializing the grid, I need to loop through each column in the datasource - and if that column is present in the Array, then I need to display it.
For example,
var ColumnNames = ["col1","col3"];
var dataSource = [{"col1": "a", "col2": "1", "col3": "11","col4": "1111"}, {"col1": "b", "col2": "2", "col3": "22","col4": "2222"}, {"col1": "c", "col2": "3", "col3": "33","col4": "3333"}, .....]
The grid should display only with the columns present in the array. Here, as shown below:
col1 col3
---------------
a 11
b 22
c 33
.......
The ColumnNames Array and dataSource actually comes from DB, based on the user selection. So, I can not hardcode column names. I tried various options (using column templates, foreach loops for building the model, etc) , but facing one or the other issue. Can someone help me out on this please?
Thanks in advance!
Regards
Neelima