ExtJS创建Grid

Ext.onReady(function()

                {

                     // 构造表格的数据 

                     var  data = [

                    {id:1,X0:'小明',X1:'沈阳',X2:'111'}, 

                    {id:2,X0:'小强',X1:'大连',X2:'222'},

                    {id:3,X0:'小力',X1:'北京',X2:'333'},

                    {id:4,X0:'小刚',X1:'上海',X2:'444'}];                                 

                    // 数据字段指定 

                     var  store =new Ext.data.JsonStore({data:data,fields:["id","X0","X1","X2" ]});

                     // 建立表格对象 

                     var grid  =new Ext.grid.GridPanel(

                    {

                          renderTo:"hello" , // 绑定的DIV ID 

                          title:"标题 " ,

                          height:150 ,

                          width:400 ,

                     // 表格头 

                    cm:new  Ext.grid.ColumnModel([

                    {header:"姓名",dataIndex:"X0",sortable:true },

                    {header:"住址",dataIndex:"X1",sortable:true },

                    {header:"电话",dataIndex:"X2",renderer:show}]),

                    store:store,

                    autoExpandColumn: 2 

                     }); 

                     }); 

-------------------------------------------------------------

id="hello"

posted @ 2011-10-20 09:46  坏小子小明  阅读(254)  评论(0)    收藏  举报