I'm evaluating the product and am also having issues with maintaining sorting state. Our grid data is repopulated via ajax calls and then the data is bound like such
$("#grid").igGrid("dataSourceObject", grid.data).igGrid("dataBind");
When the data bind completes then the sort state is reverted to the default state set when I initialized the grid using the following feature setting.
{ name: "Sorting", type: "local", columnSettings: [ {columnKey: 'NAME', currentSortDirection:'asc'} ], columnSorted: function (evt, ui) { grid.sorting.column = ui.columnKey; grid.sorting.direction = ui.direction; }}
I tried to track the changes by getting the values from the columnSorted event as you can see above, but then I can not find the correct location in which to apply them again. I tried the dataRenderedevent, but this resulted in an infintite loop.
Is there a way to maintain the sort after binding data?
Thanks for the assistance Stamen and Angel. This solution will work for me. I'm surprised it wasn't built into the grid because it doesn't seem like a strange use case
Hey Mark,
let me know if Stamen's suggestion work for you, and if not we can think of alternatives. Thanks
Angel
Hello Mark,
Because data bind and restoring the sorting state will both rerender the grid it's a better practice to try and restore the sorting state in the data source before the render operation is passed to the grid. I am attaching a small sample demonstrating how this can be achieved. Please let me know if you have questions about it.
Thank you for using Infragistics forums!
Best regards,
Stamen Stoychev