I'm using the latest version of jqGrid (v4.7.1). I have a grid which is populated with local data and has multiple pages of data. The user has sorted the data client-side. I would now like to retrieve all rows in their sorted order. Is it possible to do this?
Here's what I know:
var data = this.ui.grid.jqGrid('getGridParam', 'data');
This statement returns all rows in the grid, but returns them in their initial state. It is not affected by any sorting operation.
var rowData = this.ui.grid.jqGrid('getRowData');
This statement returns all rows in the current page, but does return them in the properly sorted order.
I was thinking about taking all the data and running it through the grid's sorting function, but that function is heavily guarded. I can get access to it by calling something like:
var data = this.ui.grid.jqGrid('getGridParam', 'data');
$.jgrid.from([])._doSort(data, 0)
However, this code still throws errors as jqGrid expects some other properties to have been set before calling _doSort. I'm confident I can get this working, but it feels like I'm hacking at some code in a really unintended fashion.
What are my options?
EDIT: This works, but it's pretty hacky:
var rowNum = this.ui.grid.getGridParam('rowNum');
this.ui.grid.setGridParam({ rowNum: 10000 }).trigger("reloadGrid");
var data = this.ui.grid.getRowData();
this.ui.grid.setGridParam({ rowNum: rowNum }).trigger("reloadGrid");