2014-01-20 5 views
0

У меня есть панель сетки Ext, как показано ниже.ExtJs 3.4: Включить кнопку выбора строки сетки

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.

Как мне это сделать?

Сердечные приветы

ответ

1

Используйте 'rowclick' слушателя (для сетки):

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

P.S. Очень плохо, когда вы используете параметр «id» в своих компонентах. Попробуйте удалить его и получить доступ к кнопке, используя другие компоненты. Извините за мой английский, ребята!

+0

Thanx Andrew.Это действительно то, что я хочу. – Rose18

Смежные вопросы