36jqGrid 数据结构 - XML结构

简介: 36jqGrid 数据结构 - XML结构

从现在的开始,jqGrid支持任意结构的XML和json数据。 在这个版本中,我们引入了xmlReader 和jsonReader。 这样,我们就可以分析和显示这些数据的数据结构,更多的信息在将来的分当中有所体现。

HTML代码举例

<html>
  <head>
    <title>jqGrid 实例</title>
  </head>
  <body>
    ···代码省略···
    <table id="list19"></table>
    ···代码省略···
  </body>
</html>

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

<Books>
<Items>
<Request>
<IsValid>True</IsValid>
<ItemSearchRequest>
<SearchIndex>Books</SearchIndex>
</ItemSearchRequest>
</Request>
<Item>
<DetailPageURL/>
<ItemAttributes>
<Author>John Grisham</Author>
<Title>A Time to Kill</Title>
<Price>12.99</Price>
<DatePub>1998-05-01</DatePub>
<ASIN>0446351230</ASIN>
</ItemAttributes>
</Item>
<Item>
<DetailPageURL/>
<ItemAttributes>
<Author>Stephen King</Author>
<Title>Blood and Smoke</Title>
<Price>24.00</Price>
<DatePub>2000-01-01</DatePub>
<ASIN>0446355453</ASIN>
</ItemAttributes>
</Item>
<Item>
<DetailPageURL/>
<ItemAttributes>
<Author>John Grisham</Author>
<Title>The Rainmaker</Title>
<Price>7.99</Price>
<DatePub>2001-12-01</DatePub>
<ASIN>0443622434</ASIN>
</ItemAttributes>
</Item>
<Item>
<DetailPageURL/>
<ItemAttributes>
<Author>Stephen King</Author>
<Title>The Green Mile</Title>
<Price>24.00</Price>
<DatePub>1992-01-01</DatePub>
<ASIN>0443622987</ASIN>
</ItemAttributes>
</Item>
<Item>
<DetailPageURL/>
<ItemAttributes>
<Author>Stephen King</Author>
<Title>Misery</Title>
<Price>7.70</Price>
<DatePub>2003-01-01</DatePub>
<ASIN>0443623452</ASIN>
</ItemAttributes>
</Item>
<Item>
<DetailPageURL/>
<ItemAttributes>
<Author>Stephen King</Author>
<Title>The Dark Half</Title>
<Price>48.00</Price>
<DatePub>1999-10-30</DatePub>
<ASIN>0443623482</ASIN>
</ItemAttributes>
</Item>
<Item>
<DetailPageURL/>
<ItemAttributes>
<Author>John Grisham</Author>
<Title>The Partner</Title>
<Price>12.99</Price>
<DatePub>2005-01-01</DatePub>
<ASIN>0443744434</ASIN>
</ItemAttributes>
</Item>
<Item>
<DetailPageURL/>
<ItemAttributes>
<Author>Stephen King</Author>
<Title>It</Title>
<Price>9.70</Price>
<DatePub>2001-10-15</DatePub>
<ASIN>0443698452</ASIN>
</ItemAttributes>
</Item>
<Item>
<DetailPageURL/>
<ItemAttributes>
<Author>Honore de Balzac</Author>
<Title>Cousin Bette</Title>
<Price>19.70</Price>
<DatePub>1991-12-01</DatePub>
<ASIN>0443691234</ASIN>
</ItemAttributes>
</Item>
<Item>
<DetailPageURL/>
<ItemAttributes>
<Author>Alexandr Pushkin</Author>
<Title>Boris Godunov</Title>
<Price>7.15</Price>
<DatePub>1999-01-01</DatePub>
<ASIN>0447791234</ASIN>
</ItemAttributes>
</Item>
<Item>
<DetailPageURL/>
<ItemAttributes>
<Author>Alice in Wonderland</Author>
<Title>Lewis Carroll</Title>
<Price>4.15</Price>
<DatePub>1999-01-01</DatePub>
<ASIN>0447791294</ASIN>
</ItemAttributes>
</Item>
</Items>
</Books>

目录
相关文章
|
6天前
|
存储 编译器 C++
【初阶数据结构】掌握二叉树遍历技巧与信息求解:深入解析四种遍历方法及树的结构与统计分析
【初阶数据结构】掌握二叉树遍历技巧与信息求解:深入解析四种遍历方法及树的结构与统计分析
|
4月前
|
存储 算法
【数据结构和算法】--- 二叉树(4)--二叉树链式结构的实现(2)
【数据结构和算法】--- 二叉树(4)--二叉树链式结构的实现(2)
33 0
|
4月前
|
存储 算法 Linux
【数据结构和算法】---二叉树(1)--树概念及结构
【数据结构和算法】---二叉树(1)--树概念及结构
43 0
|
4月前
|
存储 算法
【数据结构和算法】--队列的特殊结构-循环队列
【数据结构和算法】--队列的特殊结构-循环队列
26 0
|
2天前
|
存储 算法
【数据结构】二叉树——顺序结构——堆及其实现
【数据结构】二叉树——顺序结构——堆及其实现
|
1月前
|
存储 算法 C语言
数据结构基础详解(C语言): 二叉树的遍历_线索二叉树_树的存储结构_树与森林详解
本文从二叉树遍历入手,详细介绍了先序、中序和后序遍历方法,并探讨了如何构建二叉树及线索二叉树的概念。接着,文章讲解了树和森林的存储结构,特别是如何将树与森林转换为二叉树形式,以便利用二叉树的遍历方法。最后,讨论了树和森林的遍历算法,包括先根、后根和层次遍历。通过这些内容,读者可以全面了解二叉树及其相关概念。
|
1月前
|
存储 机器学习/深度学习 C语言
数据结构基础详解(C语言): 树与二叉树的基本类型与存储结构详解
本文介绍了树和二叉树的基本概念及性质。树是由节点组成的层次结构,其中节点的度为其分支数量,树的度为树中最大节点度数。二叉树是一种特殊的树,其节点最多有两个子节点,具有多种性质,如叶子节点数与度为2的节点数之间的关系。此外,还介绍了二叉树的不同形态,包括满二叉树、完全二叉树、二叉排序树和平衡二叉树,并探讨了二叉树的顺序存储和链式存储结构。
|
2月前
|
存储
数据结构中的 线性结构和非线性结构
这篇文章介绍了数据结构中的线性结构和非线性结构,其中线性结构包括顺序存储结构和链式存储结构,如数组、队列、链表和栈;非线性结构包括图结构、树结构、二维数组、广义表和多维数组。
|
3月前
|
存储
【数据结构】树和二叉树的概念及结构
数据结构——树和二叉树的概念及结构
66 3
【数据结构】树和二叉树的概念及结构
|
2月前
|
存储 算法 测试技术
【初阶数据结构篇】实现顺序结构二叉树(堆的实现方法)
注意传过去的参数是插入的位置,即插入前的size,在调整完后再将size++
22 0