在同一个 JQGrid 中加载多个 xml 标签
loading multiple xml tags in the same JQGrid
我的 xml 文件是这样的:
<abc>
<a>
<item>
<name>...</name>
<cost>....</cost>
</item>
.
.
.
.
</a>
<b>
<item>
<name>...</name>
<cost>....</cost>
</item>
.
.
.
.
</b>
我想在 jqgrid 上加载两个标签的值和 [不改变两个标签名称相同]。当我使用 xmlReader 两次时,它只加载后来的根值.....任何人都知道如何加载这两个标签????
读取此类 XML 数据的最简单方法是指定 xmlReader
,如下所示
xmlReader : {
root: "abc",
row: "a>item,b>item",
repeatitems: false
}
在更复杂的情况下,您可以在 xmlReader
:
中使用函数
xmlReader : {
root: "abc",
row: function (obj) {
return $("a>item,b>item", obj);
},
repeatitems: false
}
或
xmlReader : {
root: "abc",
row: function (obj) {
return $("a>item", obj).add("b>item", obj);
},
repeatitems: false
}
The corresponding demo阅读以下内容XML
<?xml version="1.0" encoding="UTF-8"?>
<abc>
<a>
<item>
<name>Name A1</name>
<cost>123</cost>
</item>
<item>
<name>Name A2</name>
<cost>234</cost>
</item>
</a>
<b>
<item>
<name>Name B1</name>
<cost>345</cost>
</item>
<item>
<name>Name B2</name>
<cost>456</cost>
</item>
</b>
</abc>
并将结果显示为
它使用代码
$("#list").jqGrid({
url: "Ambkrish.xml",
datatype: "xml",
gridview: true,
autoencode: true,
pager: "#pager",
rowNum: 10,
rowList: [10, 20, 50],
viewrecords: true,
height: "auto",
xmlReader : {
root: "abc",
row: "a>item,b>item",
repeatitems: false
},
colModel:[
{ name: "name", label: "Name" },
{ name: "cost", label: "Cost", formatter: "integer", sorttype: "integer", align: "right" }
],
cmTemplate: {width: 200},
loadonce: true
});
我的 xml 文件是这样的:
<abc>
<a>
<item>
<name>...</name>
<cost>....</cost>
</item>
.
.
.
.
</a>
<b>
<item>
<name>...</name>
<cost>....</cost>
</item>
.
.
.
.
</b>
我想在 jqgrid 上加载两个标签的值和 [不改变两个标签名称相同]。当我使用 xmlReader 两次时,它只加载后来的根值.....任何人都知道如何加载这两个标签????
读取此类 XML 数据的最简单方法是指定 xmlReader
,如下所示
xmlReader : {
root: "abc",
row: "a>item,b>item",
repeatitems: false
}
在更复杂的情况下,您可以在 xmlReader
:
xmlReader : {
root: "abc",
row: function (obj) {
return $("a>item,b>item", obj);
},
repeatitems: false
}
或
xmlReader : {
root: "abc",
row: function (obj) {
return $("a>item", obj).add("b>item", obj);
},
repeatitems: false
}
The corresponding demo阅读以下内容XML
<?xml version="1.0" encoding="UTF-8"?>
<abc>
<a>
<item>
<name>Name A1</name>
<cost>123</cost>
</item>
<item>
<name>Name A2</name>
<cost>234</cost>
</item>
</a>
<b>
<item>
<name>Name B1</name>
<cost>345</cost>
</item>
<item>
<name>Name B2</name>
<cost>456</cost>
</item>
</b>
</abc>
并将结果显示为
它使用代码
$("#list").jqGrid({
url: "Ambkrish.xml",
datatype: "xml",
gridview: true,
autoencode: true,
pager: "#pager",
rowNum: 10,
rowList: [10, 20, 50],
viewrecords: true,
height: "auto",
xmlReader : {
root: "abc",
row: "a>item,b>item",
repeatitems: false
},
colModel:[
{ name: "name", label: "Name" },
{ name: "cost", label: "Cost", formatter: "integer", sorttype: "integer", align: "right" }
],
cmTemplate: {width: 200},
loadonce: true
});