Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
Building grid dynamically
posted

Just to confirm I'm not insane--if the following works:

$( '#idGrid' ).igGrid(
 {
  ...
  features: [
   {
    name: 'GroupBy',
    columnSettings: [
     {
      columnKey: 'MpName',
      isGroupBy: true,
      dir: 'desc'
     }
    ]
   }
  ]
 }
);

...then the following should be expected to work as well, right??

var columnSettingsGroupBy = [];
...
columnSettingsGroupBy.push( { columnKey: 'MpName', isGroupBy: true, dir: 'desc' } );

$( '#idGrid' ).igGrid(
 {
  ...
  features: [
   {
    name: 'GroupBy',
    columnSettings: columnSettingsGroupBy
   }
  ]
 }
);

I have a loop iterating over column names and building my columnSettingsGroupBy array dynamically (pushing values into it based on settings saved in a file rather than being hardcoded), but ultimately the end result is the same.  So if I can confirm that the above can be expected to work...I'll know the problem probably lies within my loop somewhere (even though by the time it's done, my array looks the same).

Parents
No Data
Reply
  • 485
    Offline posted

    Hello dandy,

     

    Thank you for posting in our forum.

     

    Both of these snippets are valid, but it is recommended that the columnSettings array gets defined before you initialize and bind the grid.

    Providing some of your code that reads the file, as well as this for-loop you mentioned would be appreciated and would allow me to give you a more detailed answer.

     

    Also, do you have a requirement to modify the columnSettings array afterwards at runtime, or do you just want to construct it dynamically?

     

    If you need any additional assistance, feel free to contact me.

Children