jqGrid子网格不扩展
我确信它一定是基本的东西,但我不明白为什么我无法加载子网格:
$("#MyTable").jqGrid({
datatype: function () {
$("#MyTable").jqGrid("addRowData", 1, { Id: 1, Name: "Someone" });
},
height: 90,
colNames: ["#", "Name"],
colModel: [
{ name: "Id", index: "Id", width: 45, align: "center", sortable: false },
{ name: "Name", index: "Name", sortable: false }
],
caption: "My Table",
subGrid: true,
subGridType: function () {
alert(1);
},
subGridUrl: "myurl",
subGridModel: [ { name: ['No','Item','Qty'], width: [55,200,80] } ]
});
单击 + 符号展开子网格没有任何作用。它不会调用 myurl 来获取数据。
有人有什么想法吗?我还尝试使用 subGridRowExpanded 选项而不是 subGridModel,但仍然没有运气。
答案:
所以答案是它根本不允许子网格的数据类型设置为“本地”或函数。它仅适用于数据类型“json”,大概也适用于“xml”。
希望这对某人有帮助。
I'm sure it must be something basic, but I can't figure out why I can't get a subgrid to load:
$("#MyTable").jqGrid({
datatype: function () {
$("#MyTable").jqGrid("addRowData", 1, { Id: 1, Name: "Someone" });
},
height: 90,
colNames: ["#", "Name"],
colModel: [
{ name: "Id", index: "Id", width: 45, align: "center", sortable: false },
{ name: "Name", index: "Name", sortable: false }
],
caption: "My Table",
subGrid: true,
subGridType: function () {
alert(1);
},
subGridUrl: "myurl",
subGridModel: [ { name: ['No','Item','Qty'], width: [55,200,80] } ]
});
Clicking on the + symbol to expand the subgrid does nothing. It doesn't call myurl to fetch the data.
Anybody have any ideas? I also tried using the subGridRowExpanded option instead of subGridModel, but still no luck.
Answer:
So the answer is that it simply doesn't allow subgrids with datatype set to either "local" or to a function. It works with datatype "json" and, presumably, "xml" only.
Hope this helps someone.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的主要错误是 subgridtype 参数。
此外,如果不是真正需要,我强烈建议您不要使用
datatype
或subgridtype
作为函数。当前示例中datatype
的使用可以替换为datatype:'local'
和data: mydata
参数,其中mydata< /code> 参数定义为
Your main error is in the wrong case of writing of the subgridtype parameter.
Moreover I strictly recommend you not use
datatype
orsubgridtype
as the function if it is not really required. The usage ofdatatype
in your current example can be replaced with thedatatype:'local'
anddata: mydata
parameter wheremydata
parameter are defined as