【发布时间】:2015-09-30 12:34:08
【问题描述】:
嗨,有一个我需要在 Jqgrid 中显示的 xml。任何人都可以帮助完成这项工作。如果我在代码中遗漏了任何其他设置,请告诉我
我的xml数据:
<entry>
<properties xmlns="http://example.com" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<property>
<name>header1</name>
<value>value 1.1</value>
</property>
<property>
<name>Header2</name>
<url>http://localhost/locator.aspx</url>
<value>value 1.2 </value>
</property>
<property>
<name>header 3</name>
<value>value 1.3 </value>
</property>
</properties>
</entry>
<entry>
<properties xmlns="http://example.com" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<property>
<name>header1</name>
<value>value 2.1</value>
</property>
<property>
<name>Header2</name>
<url>http://localhost/locator.aspx</url>
<value>value 2.2 </value>
</property>
<property>
<name>header 3</name>
<value>value 2.3</value>
</property>
</properties>
</entry>
像下面这样绑定 JqGrid 但不起作用
function loadXMLDoc(data)
{
$("#loadXMLData").jqGrid({
url: 'local',
datatype: "xml",
height: 'auto',
colModel: [
{ name:xmlmap: function (obj) {
return $(obj).attr('name');
}}
, width: 80, sorttype: 'int',
xmlmap: function (obj) {
return $(obj).attr('value');
}
],
xmlReader: {
root: "properties",
row: "property",
repeatitems: false
},
loadonce: true,
rowNum: 1000
});
我需要以下格式的输出
<table border=1>
<tr>
<th>
header 1
</th>
<th>
header 2
</th>
<th>
header 3
</th>
</tr>
<tr>
<td>value 1.1</td>
<td>value 1.2</td>
<td>value 1.3</td>
</tr>
<tr>
<td>value 2.1</td>
<td>value 2.2</td>
<td>value 2.3</td>
</tr>
<tr>
<td>value 3.1</td>
<td>value 3.2</td>
<td>value 3.3</td>
</tr>
</table>
【问题讨论】:
标签: jquery xml jqgrid jqgrid-asp.net