【问题标题】:ExtJs 3.4 : Enable a button on grid row selectionExtJs 3.4:启用网格行选择按钮
【发布时间】:2014-01-20 21:44:13
【问题描述】:

我有一个 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。

我该怎么做?

亲切的问候

【问题讨论】:

    标签: javascript button extjs grid


    【解决方案1】:

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

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

    附:在组件中使用 'id' 参数时非常糟糕。尝试删除它并使用其他组件访问按钮。对不起,伙计们,我的英语不好!

    【讨论】:

    • 感谢 Andrew。这正是我想要的。
    猜你喜欢
    • 1970-01-01
    • 2014-09-25
    • 1970-01-01
    • 1970-01-01
    • 2015-05-05
    • 1970-01-01
    • 2014-01-27
    • 2011-10-03
    • 2018-07-05
    相关资源
    最近更新 更多