Extjs列表列头动态显示—合并列头

//动态显示

var columns = [];
Ext.define('OneCarAnalyzeApp.view.OneCarAnalyzeListView' ,{
    extend : 'Ext.grid.Panel',
    alias : 'widget.onecaranalyzeListView',
            title: '单车利润分析列表',
            autoWidth: true,
            autoHeight : true,
            region: "center",
            border: true,
            frame: true,
            id : 'onecaranalyzelistview',
            multiSelect: true,
            stripeRows:true//表格是否隔行换色,默认为false
            loadMask:true,   //是否在加载数据时显示遮罩效果,默认为false
            columns: columns,
            store : "OneCarAnalyzeListStore",
            tbar:[{
                text:'Excel导出',
                iconCls:'common-excel-icon',
                action : 'export'
            }],
            bbar : {
                xtype : 'pagingtoolbar',
                store: "OneCarAnalyzeListStore",
                displayInfo: true,   
                displayMsg: '显示 {0} - {1} 条,共计 {2} 条',   
                emptyMsg: "没有数据" 
            }    
}
);
   Ext.Ajax.request({
        url: window.BIZCTX_PATH + '/summary/summaryjson/selOneCarAnalyzeRowOne.action',
        success: function(response,selfobj){
            var text = response.responseText;
            var textobj=eval('('+text+')');  
            columns = textobj.result.list;
            for(var i=2;i<columns.length;i++){
                var aa = "[{ header: '金额', width:80, dataIndex: '"+columns[i].text+"', sortable: true }," +
                            "{ header: '比例(%)', wdith:80, dataIndex: '"+columns[i].text+"v', sortable: true }]" ;
                            
                    var teobj=eval('('+aa+')');  
                    columns[i].columns = teobj ;
            };
            /*
            columns.forEach(function(e,i){
                if(i>=2){
                    var aa = "[{ header: '金额', flex: 2, dataIndex: '"+e.text+"', sortable: true }," +
                            "{ header: '比例(%)', flex: 2, dataIndex: '"+e.text+"v', sortable: true }]" ;
                            
                    var teobj=eval('('+aa+')');  
                    e.columns = teobj ;
                }
            });
            */
            var store = Ext.StoreManager.get('OneCarAnalyzeListStore');
            Ext.getCmp('onecaranalyzelistview').reconfigure(store, columns);
        },
        failure: function(){
                Ext.Msg.alert('提示','加载错误,请重试');
        }
 });


//静态显示
-
Ext.define('FreightMonthApp.view.FreightMonthListView' ,{
    extend: 'Ext.grid.Panel',
    alias : 'widget.freightmonthListView',
            title: '运费收入月报表',
            autoWidth: true,
            autoHeight : true,
            region: "center",
            border: true,
            frame: true,
            store: "FreightMonthListStore",
            multiSelect: true,
            stripeRows:true//表格是否隔行换色,默认为false
            loadMask:true,   //是否在加载数据时显示遮罩效果,默认为false
            columns: [
            { header: '序号', width:35,locked:true, xtype: 'rownumberer'},
            { header: '货物名称', width : 100, dataIndex: 'goodsname',locked:true, sortable: true },
            { header: '1月', width:80, sortable: true ,
              columns: [
                { header: '数量', width:80, dataIndex: 'one', sortable: true },
                { header: '运费收入', width:80, dataIndex: 'onev', sortable: true }
              ]},
            { header: '2月', width:80, sortable: true ,
              columns: [
                { header: '数量', width:80, dataIndex: 'two', sortable: true },
                { header: '运费收入', width:80, dataIndex: 'twov', sortable: true }
              ]},
            { header: '3月', width:80, sortable: true ,
              columns: [
                { header: '数量', width:80, dataIndex: 'three', sortable: true },
                { header: '运费收入', width:80, dataIndex: 'threev', sortable: true }
              ]},
            { header: '4月', width:80, sortable: true ,
              columns: [
                { header: '数量', width:80, dataIndex: 'four', sortable: true },
                { header: '运费收入', width:80, dataIndex: 'fourv', sortable: true }
              ]},
            { header: '5月', width:80, sortable: true ,
              columns: [
                { header: '数量', width:80, dataIndex: 'five', sortable: true },
                { header: '运费收入', width:80, dataIndex: 'fivev', sortable: true }
              ]},
            { header: '6月', width:80, sortable: true ,
              columns: [
                { header: '数量', width:80, dataIndex: 'six', sortable: true },
                { header: '运费收入', width:80, dataIndex: 'sixv', sortable: true }
              ]},
            { header: '7月', width:80, sortable: true ,
              columns: [
                { header: '数量', width:80, dataIndex: 'sevenv', sortable: true },
                { header: '运费收入', width:80, dataIndex: 'sevenv', sortable: true }
              ]},
            { header: '8月', width:80, sortable: true ,
              columns: [
                { header: '数量', width:80, dataIndex: 'fight', sortable: true },
                { header: '运费收入', width:80, dataIndex: 'fightv', sortable: true }
              ]},
            { header: '9月', width:80, sortable: true ,
              columns: [
                { header: '数量', width:80, dataIndex: 'nine', sortable: true },
                { header: '运费收入', width:80, dataIndex: 'ninev', sortable: true }
              ]},
            { header: '10月', width:80, sortable: true ,
              columns: [
                { header: '数量', width:80, dataIndex: 'ten', sortable: true },
                { header: '运费收入', width:80, dataIndex: 'tenv', sortable: true }
              ]},
            { header: '11月', width:80, sortable: true ,
              columns: [
                { header: '数量', width:80, dataIndex: 'eleven', sortable: true },
                { header: '运费收入', width:80, dataIndex: 'elevenv', sortable: true }
              ]},
            { header: '12月', width:80, sortable: true ,
              columns: [
                { header: '数量', width:80, dataIndex: 'twelve', sortable: true },
                { header: '运费收入', width:80, dataIndex: 'twelvev', sortable: true }
              ]}
            ],
            tbar:[{
                text:'Excel导出',
                iconCls:'common-excel-icon',
                action : 'export'
            }],
            bbar : {
                xtype : 'pagingtoolbar',
                store: "FreightMonthListStore",
                displayInfo: true,   
                displayMsg: '显示 {0} - {1} 条,共计 {2} 条',   
                emptyMsg: "没有数据" 
            }
        
});



评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值