Reputation: 891
I am using jqGrid grouping with data local.
My data is already sorted, so I just want to display it according to the order of my data array. However, I noticed that jqGrid actually changes the order of my data when I use grouping.
I can reproduce this issue in this plunkr. The order of data should be 1 2 3 4 5 6
but instead it is displaying 1 2 4 5 6 3
I am using jqGrid 4.6.0 currently. Currently the workaround that I can think is adding a hidden column called "rankOrder" and then on loadComplete
, sort the column based on rankOrder. I have multiple tables in my application so I want to avoid doing that (adding hidden column to each table). Anybody knows better workaround of this?
UPDATE: I noticed this also happens with free jqGrid 4.8.0, here's a working demo created by user Oleg, and I forked it to reproduce my issue here
Upvotes: 0
Views: 747
Reputation: 221997
You can solve the problem of sorting of the first page during initial loading of local data by replacing data: myData, datatype: "local"
with datastr: myData, datatype: "jsonstring"
. On the other side you use local paging of data. To display the next page of data jqGrid have to sort the data to get the next page.
Thus I suppose that you need just add sortname: "OrderID"
option to the grid to solve your problem and to display the data grouped by CustomerID
and sorted by OrderID
additionally. You should stay by original data: myData, datatype: "local"
. I recommend you to add sorttype: "integer"
in the OrderID
to have 10
after 9
and not between 1
and 2
during sorting.
Upvotes: 1