zoukankan      html  css  js  c++  java
  • 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]
                });
  • 相关阅读:
    8月份的To-Do List
    Block作为返回值时的使用
    Block作为参数时的使用
    AFNetwork 作用和用法详解
    UIScrollView监听静止的数种情况
    UIAppearance
    自定义Log实现条件编译
    事件的基本概念
    ubuntu16.04下安装MySQL
    在Ubuntu16.04下搭建samba,实现linux与windows之间的资源共享
  • 原文地址:https://www.cnblogs.com/winner/p/1258965.html
Copyright © 2011-2022 走看看