Extjs gridPanel 动态指定表头

var colMArray = new Array();
colMArray = [{header : "产品代码",    dataIndex : "cpdm",    width : 100},
            {header : "代销机构代码",    dataIndex : "dxjgdm",    width : 100},
            {header : "总份额",    dataIndex : "zfe",    width : 100, align:"right"}         ];

var colQd = new Ext.grid.ColumnModel(colMArray);


function selinfo(){
    var cpdm_sel = Ext.get("cpdm").getValue();
    var dxjgdm_sel = Ext.get("dxjgdm").getValue();
    var select_method_sel = Ext.get("cpdm_radio").getValue();
    if(document.getElementById("dxjgdm_radio").checked){
        select_method_sel = Ext.get("dxjgdm_radio").getValue();
        colMArray[0] = {header : "代销机构代码",    dataIndex : "dxjgdm",    width : 100};
        colMArray[1] = {header : "产品代码",    dataIndex : "cpdm",    width : 100};
    }else{
        colMArray[0] = {header : "产品代码",    dataIndex : "cpdm",    width : 100};
        colMArray[1] = {header : "代销机构代码",    dataIndex : "dxjgdm",    width : 100};
    }
    var params = {};
    params.cpdm_sel = cpdm_sel;
    params.dxjgdm_sel = dxjgdm_sel;
    params.select_method_sel = select_method_sel;
    //params.whereStr = " and feetype in ('1','2')";
    storeCpye.baseParams = params;
    colQd = new Ext.grid.ColumnModel(colMArray);
    //gridCpye.reconfigure(storeCpye,colQd),
    storeCpye.load({
        callback : function(r, options, success) {
            if (success == true){
                gridCpye.reconfigure(storeCpye,colQd);
            }else if (success == false) {
                Ext.Msg.alert("错误", storeCpye.reader.jsonData.msg);
            }
        }
    });
}

 

posted @ 2013-09-28 18:35 残星 阅读(...) 评论(...) 编辑 收藏