I'm using a JqGrid in multiselect mode and recover the user's selection. The JqGrid is defined as follow :
$("#StatusList").jqGrid({
url: '@Url.Action("UpdateStatusList", "Inventory")',
datatype: 'json',
mtype: 'GET',
colNames: ['Status', 'statusId'],
colModel: [
{ name: 'Status', index: 'Status', align: 'left', sortable: false },
{ name: 'statusId', index: 'statusId', hidden: true}]
});
I don't have any issue for all the communication between the server and the client. Everything works fine. But I feel like I am duplicating data when filling the JqGrid with this function that sends the JSON data :
public ActionResult UpdateStatusList()
{
var jsonData = new
{
rows = (from status in DatabaseInMemory.WoodStatus.GetEntities()
select new
{
i = status.ID,
cell = new string[] { status.Name,
status.ID.ToString() }
}).ToArray()
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
As you can see the id is passed two times : - for the JSON Id. - for the hidden column that helps me recover the id from the grid.
Back to the client, the JSON Id is not hold in the selarrrow property. This property holds ids based on position in the grid. I'm using it to get the selected data, and recover the real ids.
Is JqGrid processes and hold the id passed through JSON data, or is it lost and an hidden column is always needed to keep track of the rows?