btw: the reloadGrid trigger is not working in this case, and when sorting via the GUI you can only sort by left->right order of the columns (i.e can sort by field2, field3 and then by field5, but cant field5, field2 and then by field3). Although i saw posts regarding these issues already.
Post edited 11:56 - 10/02/2014 by Steve_Suarez Post edited 11:57 - 10/02/2014 by Steve_Suarez
Hi guys, I am using the jqgrid multisort for a project. My requirement is to sort the grid using a minimum of 1 and a maximum of 3 colums and always in ascending order. At the moment, when I am using the following method,
.jqGrid('sortGrid', "Field1″, true, "asc")
.jqGrid('sortGrid', "Field2″, true, "asc");
sorting happens correctly for the first time, but on second sort jqgrid automatically gets sort in descending order and on the 3rd sort the original condition (presort state) of jqgrid is restored. Please suggest me some way of fulfilling this requirement.
When the user wants to sort the grid on multiple columns, she has to press a sort button provided on the screen. This will take her to a pop up window where all the columns of the grid by the name are shown. From these columns, she can select 1, 2 or 3 columns for sorting. An 'ok' button on the pop up will take her back to the main page. After this I execute the rest of the method. If she had selected only one field for sorting, I execute the follwing -
Now when she does any of these three actions for the very first time, everything is executed correctly, however if she tries to execute the 3rd action, for instance, second time, even though I have explicitley mentioned 'asc' as the sort criteria, the grid would sort in descending order and when the same action is done for a 3rd time the grid is restored to it's first time load state(unsorted state). After this the cycle repeats itself.
Hope this will help you in detecting the root cause of the problem.
Hi Tony, I was able to implement my requirement by using 'GridUnload' for destroying the previous sorting cirteria and order. But I have run into another problem. It seems, at least to me, that jqgrid always gives precedence to the left most column while sorting with multiSort : true.
I mean even if I am executing the following command -
where I would expect the outcome to be a grid sorted on "Field1" first and then on "Field2", the outcome is this only when "Field1" is on the left of "Field2". Whenever the "Field1" is on the right of "Field2" the actual outcome will be a grid sorted on "Field2" first and then on "Field1".
Kindly tell me, whether my observation is a mistake from my end or is it actually a part of the behaviour of jqgrid and if it's a part of the behaviour of jqgrid, whether a work around exists or not?