dojox.grid.DataGrid
创建表格
<table data-dojo-type="dojox.grid.DataGrid" data-dojo-id="grid" style="height: 90%" id="grid" data-dojo-props="rowsPerPage:'5'"> <thead> <tr> <th field="name" width="100%">项目名称</th> </tr> </thead> </table>
1、清除数据
var newStore = new dojo.data.ItemFileReadStore({data: { identifier: "", items: []}}); var grid = dijit.byId("grid"); grid.setStore(newStore);
2、增加数据
/**
* 显示地图点.
* json的格式[{"name":"name1","x":"x1","y":"y1","img":"img1","content":"content1"}...]
*/
var griddata = { //类似于主键,值唯一,唯一标示一个graphic identifier: "PROJECT_ID", //This field needs to have unique values label: "PROJECT_ID", //Name field for display. Not pertinent to a grid but may be used elsewhere. items: json }; //Create data store and bind to grid. var store = new dojo.data.ItemFileReadStore({ data:griddata }); var grid = dijit.byId('grid'); grid.setStore(store); //表格行点击的监听事件,关联到地图 dojo.connect(grid, "onRowClick", onRowClickHandler);
//点击项目名称列表 function onRowClickHandler(evt){ var clickedTaxLotId = grid.getItem(evt.rowIndex).name; alert(clickedTaxLotId.toString()); }