I have a jqGrid defined as such:
$("#tableFeedbackReports").jqGrid({
url: '/FeedbackReports/GetFeedbackReport',
datatype: 'json',
colNames: ['ColA', 'ColB', 'ColC', 'ColD'],
colModel: [{ name: 'ColA', index: 'ColA', width: 60 },
{ name: 'ColB', index: 'ColB', width: 60 },
{ name: 'ColC', index: 'ColC', width: 60 },
{ name: 'ColD', index: 'ColD', width: 60 },
/* ... and so on */
Now, when the ajax call returns, it's has to return an array of what will go into each row.
['value', 'value', 'value']
Is it possible to get jqGrid to accept key/value pairs for row data?
[{ 'ColA' : 'value', 'ColB' : 'value', 'ColC' : 'value', 'ColD' : 'value'}]
So when jqGrid loads the data, it'll automatically binds the data to the column in the model?
Have a look at the
jsonReader
option on the jqGrid Wiki, specifically itsrepeatitems
property. From that page:Their example is:
Which will process data in the following format, with key/value pairs:
] }
in http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data#json_data
element. This element describes where our data begins. In other words, this points to the array that contains the data. If we set jQuery("#gridid").jqGrid({ ... jsonReader : {root:"invdata"}, ... }); then the returned string should be
so if u select key value way ; cell should not in the content json string but rows should;
The resulting data should be:
see
"id":"1"
,"cell"
keyword is out , and the associate(key value
) array data is derectly underrows
keyword ;