javascript - JqGrid - Using formatDisplayField Option -


i'm problem using jqgrid options, better write show image: jqgrid

so, when i'm construction table body (with ajax call) i'm passing hidden field. when grouped, want show hidden field 'undefined' word (group title).

is there solution using formatdisplayfield?

what have like:

groupingview : {                     groupfield : ['cpv'],                     groupcollapse : true,                     grouporder: ['desc'],                     plusicon: 'ui-icon-circle-plus',                     minusicon: 'ui-icon-circle-minus',                     formatdisplayfield: [                     function (value) { // should cpv_parent (hidden default sent jggrid when instantiate) console.log(value); // contain cpv grouped console.log($(this)); // contain [table#ajaxtable.ajaxtable.ui-jqgrid-btable, context: table#ajaxtable.ajaxtable.ui-jqgrid-btable, constructor: function, init: function, selector: "", jquery: "1.7.2"…]                         //return string(displayvalue).substring(0, 5);                     }                     ],                     isinthesamegroup: function (x, y) {                         return string(x).substring(0, 5) === string(y).substring(0, 5);                     }                 } 

edit required, heres sample data form i'm using (from last try (using userdata)):

{"total":1,"page":1,"totalrecords":3,"userdata":{"98513295":"98000000-3"},"rows":[{"tipoconcurso":"ajuste directo (regime geral)","createdon":"2014-04-23 16:19:56","valor":15000,"cpv":98513295,"cpvparent":"98000000-3"},{"tipoconcurso":"ajuste directo (regime geral)","createdon":"2013-10-01 16:05:08","valor":15000,"cpv":98513295,"cpvparent":"98000000-3"},{"tipoconcurso":"ajuste directo (regime geral)","createdon":"2013-09-03 17:34:39","valor":15000,"cpv":98513295,"cpvparent":"98000000-3"}]} 

thanks @oleg :)

thank in advance :)

regards, marcelo

it's little difficult understand question because display abstract numbers only. understand so. make grouping cpv filed, need display field cpvparent can based on cpv value. 1 need have map cpvparent cpv. don't recommend add hidden columns more expensive.

so suggest change data

{     "total": 1,     "page": 1,     "totalrecords": 3,     "rows": [         {             "tipoconcurso": "ajuste directo (regime geral)",             "createdon": "2014-04-23 16:19:56",             "valor": 15000,             "cpv": 98513295,             "cpvparent": "98000000-3"         },         {             "tipoconcurso": "ajuste directo (regime geral)",             "createdon": "2013-10-01 16:05:08",             "valor": 15000,             "cpv": 98513295,             "cpvparent": "98000000-3"         },         {             "tipoconcurso": "ajuste directo (regime geral)",             "createdon": "2013-09-03 17:34:39",             "valor": 15000,             "cpv": 98513295,             "cpvparent": "98000000-3"         }     ] } 

to following:

{     "total": 1,     "page": 1,     "totalrecords": 3,     "userdata": {         "98513295": "98000000-3",         "97123456": "97000000-2"     }     "rows": [         {             "tipoconcurso": "ajuste directo (regime geral)",             "createdon": "2014-04-23 16:19:56",             "valor": 15000,             "cpv": 97123456,             "cpvparent": "98000000-3"         },         {             "tipoconcurso": "ajuste directo (regime geral)",             "createdon": "2013-10-01 16:05:08",             "valor": 15000,             "cpv": 98513295         },         {             "tipoconcurso": "ajuste directo (regime geral)",             "createdon": "2013-09-03 17:34:39",             "valor": 15000,             "cpv": 98513295         }     ] } 

inside of formatdisplayfield callback can userdata parameter (the name of parameter userdata, json data have have userdata in other case). userdata[value] "98000000-3" key "98513295":

groupingview: {     groupfield: ["cpv"],     ...     formatdisplayfield: [         function (value) {             var userdata = $(this).jqgrid("getgridparam", "userdata");             return userdata[value];         }     ] } 

such way work , need prepare data on server side in above format.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -