繁体   English   中英

ExtJs 3.4:启用网格行选择上的按钮

[英]ExtJs 3.4 : Enable a button on grid row selection

我有一个Ext网格面板,如下所示。

var plannedGrid = new Ext.grid.GridPanel({
store : plannedGridStore,
cm : new Ext.grid.ColumnModel([ selectModel, {
    sortable : true,
    header : "Drop/Pick Loc",
    dataIndex : 'locationName',
    width : 170,
    renderer : function(value, metaData, record, rowIndex,
            colIndex, store) {
        var refColor = record.data.tourTypeColor;
        //console.log(record);
        metaData.attr = 'style="background-color:' + refColor + ';"';
        return record.get('locationName');
    }
}, {
    xtype : 'actioncolumn',
    header : "GPS",
    items : [ {
        icon : 'images/gps.jpg',
        tooltop : 'Get GPS',
        handler : function(grid, rowIndex, colIndex) {
            var rec = grid.getStore().getAt(rowIndex);
            alert("Edit " + rec.get('locationName'));
        }
    } ]
}, {
    header : "EST.Un/Load Time",
    sortable : true,
    dataIndex : 'estimatedTime',
    width : 100
}, {
    header : "",
    sortable : true,
    dataIndex : 'colorCode',
    width : 30
} ]),

sm : selectModel,
//width : 435,
height : 400,
//autoHeight : true,
autoWidth : true,
frame : true,
iconCls : 'icon-grid'/*,
listener : {
    selectionchange : function() {
        Ext.getCmp('btnHold').enable();
    }
}*/

//renderTo : document.body
});

该网格面板的数据来自另一个网格。 而且我在按钮组中也有一个按钮,如下所示。

{
                    text : 'Hold Drop/Pick',
                    id : 'btnHold',
                    iconCls : 'add',
                    width : 120,
                    // textAlign: 'center',
                    //style : 'margin:5px',
                    style : {
                        textAlign: 'center',
                        margin : '5px'
                    },
                    disabled : true
                }

此按钮被禁用。 我想要的是,当用户单击网格面板的一行时,需要启用此按钮。

我正在使用ExtJs 3.4。

我该怎么办?

亲切的问候

使用“ rowclick”监听器(用于网格):

listeners: {
    rowclick: function(grid, idx){
        Ext.getCmp('btnHold').enable();
    }
}

PS:在组件中使用“ id”参数时,这非常糟糕。 尝试将其删除,并使用其他组件来访问按钮。 抱歉,我的英文,伙计们!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM