@import "dojo/dojo/resources/dojo.css";
@import "dojo/dijit/themes/tundra/tundra.css";
@import "dojo/dojox/grid/_grid/tundraGrid.css";
备注:dojo\dojox\grid里原本是没有Grid.js的,需要把compatGrid.tar.gz解压到当前文件夹。
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dojox.grid.Grid");
<div dojoType="dojo.data.ItemFileReadStore" jsId="wishStore" url="c.json"></div>
<table id="grid" dojoType="dojox.grid.Grid" store="wishStore" query="{wishId:'*'}" clientSort="true">
<thead>
<tr>
<th field="discription" width="15em">Cigar</th>
<th field="size">length/ring</th>
<th field="origin" >origin</th>
<th field="wrapper" >wrapper</th>
<th field="shape" >shape</th>
</tr>
</thead>
</table>
query使用散列字面量来定义过滤标准。 ="{wishId:'*'}"意思就是匹配所有具有wishId属性的项。
c.json
{
"identifier":"wishId",
"label":"discription",
"items":
[
{
"wishId":4455,"discription":"描述1",
"size":"7-50","origin":"Nicaggg",
"wrapper":"Corojo","shape":"steright"
},
{
"wishId":4456,"discription":"描述2",
"size":"7-53","origin":"Nicaggg",
"wrapper":"Corojo","shape":"steright"
},
{
"wishId":4457,"discription":"描述3",
"size":"7-54","origin":"Nicaggg",
"wrapper":"Corojo","shape":"steright"
}
]
}
备注:json必须最外层包一个{}或 [],否则调用会报错
可排序,可拖拽
另:html和json的编码格式都应为utf-8,否则中文乱码