?Ext.onReady(function(){ ??? Ext.BLANK_IMAGE_URL = 'extjs/resources/images/default/s.gif'; ??? Ext.QuickTips.init(); ??? var sm = new Ext.grid.CheckboxSelectionModel(); ??? var cm = new Ext.grid.ColumnModel([ ??????? new Ext.grid.RowNumberer(), ??????? sm, ??????? {header:'编号',dataIndex:'id',sortable:true},//设置编号排序 ??????? {header:'名称',dataIndex:'name'}, ??????? {header:'描述',dataIndex:'descn'}, ??????? {header:'其他',dataIndex:'other'} ??? ]); ??? ??? //proxy直接去读取josn数据 ??? var ds = new Ext.data.Store({ ??????? proxy: new Ext.data.HttpProxy({url:'gridjson.jsp'}),//提交的页面??????? ??????? reader: new Ext.data.JsonReader({ ??????????? totalProperty: 'totalProperty', ??????????? root: 'root', ??????????? successProperty :'success' ??????? }, [ ??????????? {name: 'id',mapping:'id',type:'int'}, ??????????? {name: 'name',mapping:'name',type:'string'}, ??????????? {name: 'descn',mapping:'descn',type:'string'}, ??????????? {name: 'other',mapping:'other',type:'string'} ??????? ]) ??? });
??? //设置分页 ??? var grid = new Ext.grid.GridPanel({ ??????? el: 'grid3', //页面对应的层ID ??????? ds: ds, ??????? sm: sm, ??????? cm: cm, ??????? width:700, ??????? height:280, ??????? bbar: new Ext.PagingToolbar({ ??????????? pageSize: 10, ??????????? store: ds, ??????????? displayInfo: true, ??????????? displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条', ??????????? emptyMsg: "没有记录" ??????? }) ??? }); ??? //el:指定html元素用于显示grid ??? grid.render();//渲染表格 ??? ds.load({params:{start:0, limit:10}}); });
|