如何在具有CheckBox选择模型的Ext Grid中的columnmove()之后获取修改后的列

时间:2017-08-16 16:28:45

标签: extjs grid

我有一个带CheckBox选择模型的Ext Grid,我已经使列可移动了。移动列后,我无法检索列的dataindex,如何获取?我有单元模态,我用

完美地检索它
var sm = Ext.create('Ext.selection.CheckboxModel', {
        mode: 'SIMPLE',
        checkOnly: true,
        listeners: {
            selectionchange: function(sm, selected, eOpts) {
                listCB = selected;
                var gridID = Ext.getCmp('CiEditGrid');
                if(selected.length > 0){
                    gridID.getView().removeRowCls(0, 'hidden');
                    gridID.getView().addRowCls(0, 'custom-column1');
                    bEnableRow = true;
                }else{
                    gridID.getView().addRowCls(0, 'hidden');
                }
            },
            beforeselect: function(selModel, record, index) {
                var gridID = Ext.getCmp('CiEditGrid');
                popupIndex=index;
                colIndex=ColumnIndex;
                EditedValues.push({
                    colvalue:colIndex,
                    rowvalue:popupIndex
                });
                if (!((ColumnIndex == undefined || ColumnIndex == 0)))
                    return false;
            },
            beforedeselect: function(selModel, record, index) {
                if (!(ColumnIndex == undefined || ColumnIndex == 0))
                    return false;
            },
        }
    });

var CiGrid = Ext.create('Ext.grid.Panel',{

store: mystore,
columns: datastore.columns,
selType: 'cellmodel',  
selModel: sm,
id:'CiEditGrid',
height: 775,
columnLines: true,
enableColumnHide:false, 
viewConfig: {
                forceFit: false,
                deferEmptyText: false,
                stripeRows: true,
                emptyText :'<div class="emptyTextClass">'+noRecordsFoundMsg+'</div>'
            },
lockedViewConfig: {
    emptyText: ''
},
listeners: {
    afterrender: function(grid, eOpts){
        var gridIndxArray = grid.columns;
        for(var i=0; i<gridIndxArray.length; i++){
            var Indx = i-1; 
            if(Indx == -1)
                Indx = 0;
            ColumnIndexArray.push({
                dataIndx:gridIndxArray[i].dataIndex,
                StoreIndx:Indx
            });
        }
    },
    columnmove: function(ct, column, fromIdx, toIdx, eOpts){
        isColumnreconfigured = true;
        fromCMIdx = fromIdx;
        toCMIdx = toIdx;
    },
    itemclick: function(data, record, item, index, e, eOpts){
        popupIndex = index;
        var position = data.getPositionByEvent(e);
        ColumnIndex = position.column;
        if(index == 0){
            multiCol.push({
                colIndex:ColumnIndex
            });
        }
        if(isColumnreconfigured){
            for(var i=0; i<ColumnIndexArray.length; i++){
                if(selModel.getHeaderCt().getHeaderAtIndex(colIndex).dataIndex == ColumnIndexArray[i].dataIndx){ //Not getting the value in selModel.getHeaderCt().getHeaderAtIndex(colIndex).dataIndex
                    colIndex = ColumnIndexArray[i].StoreIndx;
                    break;
                }
            }
        }
    }
},  
cls: 'custom-dirty', 
layout:'fit',  
border: false,
autoWidth:true,  
plugins: [cellEditing],
renderTo:'grid'

});

未获取“selModel.getHeaderCt()。getHeaderAtIndex(colIndex).dataIndex”中的值

1 个答案:

答案 0 :(得分:0)

如果您想获取已移动列的{ dates: [ ISODate("2015-08-17T08:15:05.479Z"), ISODate("2015-08-17T08:15:05.479Z"), ISODate("2015-08-17T08:15:05.479Z"), ... ] } ,可以在dataIndex侦听器中执行此操作,如下所示:

columnmove

值得注意的是,columnmove: function (ct, column, fromIndex, toIndex, eOpts) { var dataIndex = column.dataIndex; // ... }, 事件具有columnmove参数,但它是列的可见索引。要获取列的真实索引,可以调用column.getIndex()

如果您希望在移动后获取所有列,可以调用getGridColumns()grid header container方法。

拥有网格,您可以获得所有列:

toIndex