gpt4 book ai didi

c# - ASP.NET MVC/JqGrid : Is the JSON Id processed and recoverable?

转载 作者:行者123 更新时间:2023-11-30 18:40:04 25 4
gpt4 key购买 nike

我在多选模式下使用 JqGrid 并恢复用户的选择。 JqG​​rid 定义如下:

$("#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}]
});

我对服务器和客户端之间的所有通信没有任何问题。一切正常。但是我觉得在使用发送 JSON 数据的函数填充 JqGrid 时我在复制数据:

  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);
}

如您所见,id 被传递了两次: - 对于 JSON ID。 - 用于帮助我从网格中恢复 ID 的隐藏列。

返回客户端,JSON Id 不保存在 selarrrow 属性中。此属性根据网格中的位置保存 id。我正在使用它来获取选定的数据,并恢复真实的 ID。

JqGrid 是否处理并保存通过 JSON 数据传递的 id,或者它是否丢失并且始终需要一个隐藏列来跟踪行?

最佳答案

您应该将 i = status.ID 更改为 id = status.ID

关于c# - ASP.NET MVC/JqGrid : Is the JSON Id processed and recoverable?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7107916/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com