首先所有选项jsonReader: {repeatitems: false, id: "0"}
是不正确的。在使用默认repeatitems: true
设置的情况下,可以使用整数值id
。在表示网格的行的数据看起来像数组["1", "Cell2"]
而不是具有命名属性{"Cell1": 1, "Cell2": "stuff"}
的对象。如果Cell1
包含您希望用作网格行的唯一id
的值,则应使用jsonReader: {repeatitems: false, id: "Cell1"}
。
现在回到你的主要问题。我建议你将数据的格式从
{
"total": 1,
"page": "1",
"records": 1,
"rows": [
{
"Cell1": 1,
"Cell2": "stuff",
"Cell3": {
"date": "2013-06-02 10:56:00",
"timezone_type": 3,
"timezone": "UTC"
}
}
]
}
改变
{
"total": 1,
"page": "1",
"records": 1,
"rows": [
{
"Cell1": 1,
"Cell2": "stuff"
}
],
"userdata": {
"1": {
"date": "2013-06-02 10:56:00",
"timezone_type": 3,
"timezone": "UTC"
}
}
}
我要评论我的建议,以便它可以很清楚其他用户了。列Cell1
包含id
。我建议的userdata
的结构是来自rowid(值为Cell1
)的地图和您最初需要保存为"Cell3"
的自定义信息。
如果你需要的地方在你的代码有"Cell3"
值的代码就会像下面
onSelectRow: function (rowid) {
var cell3 = $(this).jqGrid("getGridParam", "userData")[rowid];
// now you can use cell3 which coniains the object like
// {
// "date": "2013-06-02 10:56:00",
// "timezone_type": 3,
// "timezone": "UTC"
// }
}
这将是更好,如果你包括你用更饱满的JavaScript代码。例如'datatype'的值非常重要。如果你使用'datatype:“json”',那么使用'loadonce:true'是很重要的。你是否在TreeGrid或其他不是简单的网格中加载数据? – Oleg
@Oleg目前我网的样子: 数据类型: “JSON”, \t \t jsonReader:{ \t \t \t根: “行”, \t \t \t页: “页”, \t \t \t总:“总“ \t \t \t记载: ”记录“, \t \t \t repeatitems:假的, \t \t \t ID:” 0" \t \t},\t排序:真实, viewrecords:真实, gridview的:真正的, \t autowidth:真实, \t multipleSearch:真, 我没有负载一旦设置和数据类型是JSON。请让我知道是否有任何其他信息,你需要和再次感谢 – PcGuy