jquery - jqGrid - cell data dispappears after sorting -
i'm generating jqgrid table in each cell displays data multiple data elements. example first column of each row contains name, group, subgroup, , personid, each displayed on new line. each of these data elements part of jsonstring pass in server. example data:
{"rows":[ { "name":"barnes, bill alan", "group":"11111", "subgroup":"11", "personid":"050" }] }
i'm setting datatype: jsonstring
, gridview: true
, loadonce: true
the table loads fine initially, when sort table, group, subgroup, , personid data elements displayed undefined
. i'm using custom formatter format display , when step thru code see third param (i named rowobject) doesn't contain group, subgroup, or personid data did on initial load.
my formatter function:
function col1formatter(value, options, rowobject) { return rowobject.name + "<br/>" + rowobject.roster + "<br/>" + rowobject.subroster + "<br/>" + rowobject.personid }
my colmodel (just first column):
colmodel: [{ label: "group", name: "name", width: 100, classes:"tablecell_middle errorresultscol_line", formatter: col1formatter}], ...
hope that's enough information answer question: why losing roster, subroster, personid when sort table?
jsfiddle example. don't have of css styling applied example, if click on 1 of column headers after grid loads see many of data elements become "undefined": https://jsfiddle.net/6ljyt0oh/29/
sorry, jsfiddle example don't work @ all, code very dirty. defined formatter
in columns, don't defined neither unformat
nor sorttype
or sortfunc
. means informs jqgrid how display data, not how data , how sort there.
you should never define formatter
without unformatter (unformat
callback). recommend use datatype: "local"
instead of datatype: "jsonstring"
. makes properties of initial data permanently available in local data. simplify sorting of data.
you use commercial guriddo jqgrid js 5.0.2. develop alternative fork of jqgrid: free jqgrid in current version 4.12.1. know functionality of free jqgrid , functionality of old jqgrid (till version 4.7). example free jqgrid allows specify sortfunc
column have parameters a, b, direction, aitem, bitem
, aitem
, bitem
full compared items. allows easy specify custom sorting functions every input data. the demo, loads data many custom properties , sorts data based on values of custom properties. another demo shows how 1 can use searching dialog custom properties holding no hidden columns properties.
Comments
Post a Comment