Grid与Store的最简单的例子

Ext.onReady(
    //Store的创建步骤
    function()
    {
     //定义Record
     var User=Ext.data.Record.create(
      [
       {name:'id'},
       {name:'name'},
       {name:'sex'}
      ]
     );
     
     //创建Store
     var store=new Ext.data.Store(
      {
       url:'User.xml',//数据源
       reader:new Ext.data.XmlReader(
         {
          id:'id',//主键
          totalRecords:'',//总行数
          record:'row'//节点选择
         },
         User//能够解析的记录集
        )//解析器
      }
     );
     store.load();
     
     //定义Grid的表头
     var cm=new Ext.grid.ColumnModel(
      [
       {header:'姓名',dataIndex:'name',sortable:true},//可排序
       {header:'性别',dataIndex:'sex',sortable:true},
       {header:'编号',dataIndex:'id',sortable:false}//不可排序
      ]
     );        
     
     //创建Grid
     var grid=new Ext.grid.EditorGridPanel(
      {
       store:store,
       cm:cm,
       renderTo:'paneldiv',
       width:300,
       height:200,
       title:'cs'
      }
     );
    }    
   );
posted @ 2008-07-21 11:42  kuailewangzi1212  阅读(341)  评论(0编辑  收藏  举报