从现在的开始,jqGrid支持任意结构的XML和json数据。 在这个版本中,我们引入了xmlReader 和jsonReader。 这样,我们就可以分析和显示这些数据的数据结构,更多的信息在将来的分当中有所体现。
jqGrid 实例
···代码省略···
···代码省略···
javascript代码举例
$(function(){
pageInit();
});
function pageInit(){
jQuery("#list19").jqGrid({
url : 'books.xml',
datatype : "xml",
colNames : [ "Author", "Title", "Price", "Published Date" ],
colModel : [
{name : "Author",index : "Author",width : 120,xmlmap : "ItemAttributes>Author"},
{name : "Title",index : "Title",width : 180,xmlmap : "ItemAttributes>Title"},
{name : "Price",index : "Manufacturer",width : 100,align : "right",xmlmap : "ItemAttributes>Price",sorttype : "float"},
{name : "DatePub",index : "ProductGroup",width : 130,xmlmap : "ItemAttributes>DatePub",sorttype : "date"}
],
height : 250,
rowNum : 10,
rowList : [ 10, 20, 30 ],
viewrecords : true,
loadonce : true,
xmlReader : {
root : "Items",
row : "Item",
repeatitems : false,
id : "ASIN"
},
caption : "XML Mapping example"
});
}
books.xml
True
Books
John Grisham
A Time to Kill
12.99
1998-05-01
0446351230
Stephen King
Blood and Smoke
24.00
2000-01-01
0446355453
John Grisham
The Rainmaker
7.99
2001-12-01
0443622434
Stephen King
The Green Mile
24.00
1992-01-01
0443622987
Stephen King
Misery
7.70
2003-01-01
0443623452
Stephen King
The Dark Half
48.00
1999-10-30
0443623482
John Grisham
The Partner
12.99
2005-01-01
0443744434
Stephen King
It
9.70
2001-10-15
0443698452
Honore de Balzac
Cousin Bette
19.70
1991-12-01
0443691234
Alexandr Pushkin
Boris Godunov
7.15
1999-01-01
0447791234
Alice in Wonderland
Lewis Carroll
4.15
1999-01-01
0447791294