javascript - JqGrid not able to bind JSON data with "dot" -


i have json response server trying bind jqgrid. however, response json string has "dot" part of object name. unable jqgrid work "dot"

here sample fiddle problem facing http://jsfiddle.net/sharathchandramg/rpdfrb0l/2/

$("#grid").jqgrid({ data: data, datatype: "local", height: 250, colnames: ['name', 'cluster', 'location'], colmodel: [{     name: 'name',     width: 120 }, {     name: 'metrics.cluster.first.value',     width: 60,     jsonmap: function (obj) {          return obj.metrics['cluster.first'].value     } }, {     name: 'metrics.location-latitude.value',     width: 60 }, ], caption: "example"   }); 

as shown fiddle, not able bind property "cluster.first" while using jsonmap. whereas if property name "location-latitude" grid works fine.

let me know doing wrong.

the reason easy. property jsonmap ignored in case of usage datatype: "local" in jqgrid 4.6. changed behavior in free jqgrid (see the wiki). 1 possible solution use free jqgrid 4.8 or higher instead of jqgrid 4.6.

one more simple way solve problem usage of datatype: "jsonstring". can verified

$("#grid").jqgrid({     datastr: data,     datatype: "jsonstring",     height: "auto",     colnames: ['name', 'cluster', 'location'],     colmodel: [{         name: 'name',         width: 120     }, {         name: 'metrics_cluster_first_value',         width: 60,         jsonmap: function (obj) {             return obj.metrics['cluster.first'].value         }     }, {         name: 'metrics_location_latitude_value',         jsonmap: 'metrics.location-latitude.value',         width: 60     }],     caption: "example" }); 

see http://jsfiddle.net/olegki/rpdfrb0l/5/. can see additionally changed name property of colmodel items have no dots inside. recommend follow rule always.


Comments

Popular posts from this blog

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

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -