I want to sort the rows by one of the column name after adding any new row in jqgrid.How we can do that? I am using inline add for adding any new record.Do we need to write anything in addrowparams? Please help
Asked
Active
Viewed 145 times
1 Answers
0
Sorting is almost the same as reloading the grid. You can use .trigger("reloadGrid");
after adding any new record. You can do this inside of aftersavefunc
callback for example:
aftersavefunc: function() {
var $self = $(this);
setTimeout(function () {
$self.trigger("reloadGrid", [{current: true}]);
}, 0);
}
You didn't posted any code and don't included the version of jqGrid, which you use, and even the fork, which you use (free jqGrid, commercial Guriddo jqGrid JS or an old jqGrid in version <=4,7). Thus I can't point you more exact place where you should to include the above aftersavefunc
callback. See the demo from the answer in case if you use "free jqGrid" fork, which I develop.

Oleg
- 220,925
- 34
- 403
- 798
-
Thanks @Oleg. I have one more question Can we display the newly added row on current page? By default it is getting added at the end of the table.I am using free jqgrid – ioit Dec 17 '17 at 12:08
-
@ioit: You are welcome! I can repeat that I can't help you if you post so small description of your problem: no JavaScript code, no information about the version and the fork of jqGrid, which you use. I don't know even which kind of grid you use (simple grid, TreeGrid, grid with subgrids, grid with data grouping and so on) and whether you use local data or saves the data on the server (`datatype` and `editurl` are unknown). It's very difficult to write the answer on your question thinking about all possibility which are unknown for me. – Oleg Dec 17 '17 at 12:13