jqGrid row IDs and custom info with JSON data
I am having an issue with the using jqGrid with JSON data returned from the server.
I have a grid that is displaying different types of objects – and since the objects are different types, two could have the same ID. jqGrid seems to use the id field if the data to set the dom id of the row, so I end up having two rows with the same dom id.
Is there any way I can customize how jqGrid assigns ids to the table rows?
Additionally, if I am sending back JSON data that I don't want to display in the grid (for example, the URL to view the whole record) – is there any way to get at it later ? getRowData() seems to only return data displayed in TDs in the grid, not in the original JSON data. userdata seems to only work for the entire table, not for individual rows.. or am开发者_Python百科 I mistaken?
Thanks for any help.
In your JSON object that is coming into the jqGrid can you make your id field a different name that means something to you.
[ { customId: 'A13' }, {customId: 'B13'} ]
// do define two widgets A and B with the same ID of 13
To hold miscellanous data about rows you can just store them as hidden columns, these will return when you perform getRowData();
$('#myGrid').jqGrid({
...
colNames: ['Title', 'Price', 'HiddenLink', 'HiddenSKU'],
colModel: [
{ name: 'Title', index: 'Title' },
{ name: 'Price', index: 'Price' },
{ name: 'HiddenLink', index: 'HiddenLink', hidden: true },
{ name: 'HiddenSKU' , index: 'HiddenSKU' , hidden: true }
],
...
};
精彩评论