I am using IG version 14.1 and trying to sort the iggrid on button click.I have a sort button inside one of the grid column and on click of that button i am calling th igGridSorting function to short the grid data but it doesn't seems to be working.
Inside the button click i am calling following line of code to sort the grid:
$("#grid_2603").igGridSorting("sortColumn", 1, "asc");
-Thanks
Hello Ashish,
If you have any questions or concerns or if you need further assistance please let me know.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://es.infragistics.com/support
Hello Ashish ,
The rows get re-rendered when sorted so the “click” event handler should be added via the delegate() function in order to ensure the event will stay hooked after the buttons are recreated.
For example:
$( "body" ).delegate( "button.btnSort","click", function() {
$("#grid").igGridSorting("sortColumn", 1, "asc");
});
Also in the above code for the sorting the “asc” string is passed as the third parameter of the method.
When “asc” is passed the grid will sort the column in ascending order. If you want to sort in descending order you need to pass the “desc” instead of “asc”.
Let me know if you have any questions.
Developer Support Engineer II
Thanks for your reply.
Sample attached by you doen't seems to be working properly.It sorts the grid only once.Moreover if We will first sort the grid using any of the column sort and than try to sort it using button it will not work at all.Can you please check.
Thank you for posting in our forum.
Make sure that “grid_2603” is the id of the grid element.
I’ve attached an sample that has a column with a template that has a button and on click of the button the same code is used:
And the related column is properly sorted in ascending order.
Please refer to the attached sample and let me know if you have any questions.