`
starbhhc
  • 浏览: 633384 次
  • 性别: Icon_minigender_2
  • 来自: 深圳
社区版块
存档分类
最新评论

Ext 动态添加grid 列数

阅读更多
Ext 动态添加grid 列数

在做报表的时候,需要将grid的列数做成活的,列数有数据库里的字段确定,这据需要将grid的列数做成动态的,经过多次实验已成,如下:

后台返回的json:

                {'action':true,'message':'error!','data':[
                {'number':'1','text1': '3','info1': '4','special1': '5'}
                ],'columModle':[
                {'header': '序号','dataIndex': 'number','width':40},
                {'header': '编码','dataIndex': 'text1'},
                {'header': '名称','dataIndex': 'info1'},
                {'header': '金额','dataIndex': 'special1'}
                ],'fieldsNames':[{name: 'number'},
                {name: 'text1'}, {name: 'info1'},
                {name: 'special1'}]}



            var cm = new Ext.grid.ColumnModel(json.columModle);
            var ds = new Ext.data.JsonStore({
            data:json.data,
            fields:json.fieldsNames
            });
                                       
            var grid = new Ext.grid.GridPanel({
            region: 'center',
            split: true,
            border:false,
            cm:cm,
            ds:ds
            });
            grid.render(document.body);
           
            new Ext.Viewport({
              layout: 'border',
              split: true,
              items: [grid]
            });
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics