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
30
igGrid loses sort after dataBind
posted

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?

Parents
No Data
Reply
  • 5513
    Verified Answer
    Offline posted

    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

    sample.zip
Children