1

I have a jqgrid with some data loaded initially and some data added dynamically. The function

$('#mygrid').jqGrid('getGridParam','data');

retrieves correctly all grid data, but doesn't care about any sort order applied by user clicking on the sort icons on grid headers.

There is any additional function or parameter that i can use to get sorted data as showed by jqGrid table?

brillantef
  • 134
  • 8

3 Answers3

3

I've found the answer by myself...

This is the correct method in order to retrieve sorted data:

$('#myJqGrid').jqGrid('getRowData');

I hope that this can be helpful to someone.

brillantef
  • 134
  • 8
1

this information may be helpful to you.

$("#mygrid").jqGrid({ sortname: 'id', sortorder: "desc" });

here sortname 'id' means it sort data by id column desc order.

Sanjay
  • 2,481
  • 1
  • 13
  • 28
  • Hi Sanjay, if I'm not wrong, looks like that sortname and sortorder set an initial order of jqgrid data. What I would like to achieve is to retrieve the jqGrid dataset ordered according to the sort criteria of the current view of the grid (that maybe could be different from the initial sort criteria). – brillantef Sep 08 '14 at 11:43
  • before fill up data in jqrid ,make it asc or desc order. – Sanjay Sep 09 '14 at 05:19
1

The only way to implement what you requirements is the usage of "subclassing" of internal $.jgrid.from jqGrid class. select method of $.jgrid.from will be used to get sorted query results (the full sorted and filtered data before cutting the first page only from the results). I described the technique in the answer.

UPDATED: Free jqGrid has now simple way to get the data. One need just use getGridParam to get the value of lastSelectedData parameter. See the demos included in the answer or another one.

Oleg
  • 220,925
  • 34
  • 403
  • 798