i have code available here: https://jsfiddle.net/zqlp4yrg/41/
datatype "local" not json.
$("#jqgrid").jqgrid({ url: "/echo/json/", // use jsfiddle echo service postdata: { json: json.stringify(serverresponse) // needed jsfiddle echo service }, mtype: "post", // needed jsfiddle echo service datatype: "json", colmodel: [ { label: 'catid', name: 'catid', key: true, width: 30 }, { label: 'inventorydate', name: 'inventorydate', width: 70 }, { label: 'productname', name: 'productname', width: 150 }, { label: 'remainingquantity', name: 'remainingquantity', width: 150, summarytype: 'sum', sortable: true } ], iconset: "fontawesome", viewrecords: true, rowlist: [20,30,50], width: 780, height: 250, rownum: 20, sortname: "productname", grouping: true, groupingview: { groupfield: ["catid"], groupcolumnshow: [true], grouptext: [ "catid: <b>{0}</b>" ], grouporder: ["asc"], groupsummary: [true], groupsummarypos: ["header"], groupcollapse: true } });
in here want sort remaining quantity based on summary value in header. please help.
your demo has many small problems:
- first of write usage of datatype "local", use
datatype: "json"
in demo. moreover, use noloadonce: true
option , noforceclientsorting: true
option. means the server responsible sorting data. moreover, if use grouping, data returned server have sorted (on server) bothgroupingview.groupfield
(catid
in case) ,sortname
(remainingquantity
in case). data use source not sorted correctly. 1 sees, example, jqgrid displays twocatid: 2
, 2catid: 3
groups. - you can fix problem adding
loadonce: true
,forceclientsorting: true
options, use old version of free jqgrid (4.11.1), not supportforceclientsorting: true
. have upgrade latest version (4.14.0) of free jqgrid able sort , group data returned server on client before displaying. - the source data, contains integer data returned server strings. moreover, data items contains spaces (
" 16"
instead of"16"
or16
). changes order of sorting data. - you should use
sorttype
(for examplesorttype: "integer"
) sort data in column corresponds type of data. - to sort date column correctly should use both
sorttype: "date"
,formatter: "date"
formatoptions
(in case:formatoptions: { srcformat: "d/m/y h:i:s", newformat: "d/m/y h:i:s" }
) - if want options
rownum
,rowlist
,viewrecords
work, grid have have @ least 1 pager. skippager: true
ortoppager: true
(or both) options.
the fixed demo https://jsfiddle.net/olegki/zqlp4yrg/43/. removed groupingview.groupollapse: true
, height: 250
make easy examine results. settings not important main problem.
Comments
Post a Comment