2016-11-22 7 views
0

Есть ли способ ограничить действие столбца проверки только флажком и ограничить область ячеек. образец кода для столбца проверки, который я скопировал из документов.Ext.grid.column.Проверьте событие щелчка на CheckBox, а не на всю область ячеек

var store = Ext.create('Ext.data.Store', { 
    fields: ['name', 'email', 'phone', 'active'], 
    data: [{ 
     name: 'Lisa', 
     email: '[email protected]', 
     phone: '555-111-1224', 
     active: true 
    }, { 
     name: 'Bart', 
     email: '[email protected]', 
     phone: '555-222-1234', 
     active: true 
    }, { 
     name: 'Homer', 
     email: '[email protected]', 
     phone: '555-222-1244', 
     active: false 
    }, { 
     name: 'Marge', 
     email: '[email protected]', 
     phone: '555-222-1254', 
     active: true 
    }] 
}); 

Ext.create('Ext.grid.Panel', { 
    title: 'Simpsons', 
    height: 200, 
    width: 400, 
    renderTo: Ext.getBody(), 
    store: store, 
    columns: [{ 
     text: 'Name', 
     dataIndex: 'name' 
    }, { 
     text: 'Email', 
     dataIndex: 'email', 
     flex: 1 
    }, { 
     text: 'Phone', 
     dataIndex: 'phone' 
    }, { 
     xtype: 'checkcolumn', 
     text: 'Active', 
     dataIndex: 'active' 
    }] 
}); 

Просьба помочь мне в этом.

+0

Вы хотите установить флажок, не выбирая строку? –

+0

Вы можете написать свой собственный класс. Вы посмотрели исходный код. – Alexander

+0

Какую версию ExtJS вы используете? Я имею в виду полную версию (т.е. 4.1.1) –

ответ

2

Это решение будет работать на каждой версии ExtJS с 4.2.0 до 4.2.6.

Ext.define('CheckColumn', { 
    override: 'Ext.grid.column.' + (!!Ext.grid.column.Check ? 'Check': 'CheckColumn'), 
    processEvent: function(type, view, cell, recordIndex, cellIndex, e, record, row) { 
     var me = this, 
      key = type === 'keydown' && e.getKey(), 
      mousedown = type == 'mousedown'; 

     if (mousedown && !Ext.fly(e.getTarget()).hasCls('x-grid-checkcolumn')) { 
      return !me.stopSelection; 
     } 

     me.callParent([type, view, cell, recordIndex, cellIndex, e, record, row]); 
    } 
}); 
+0

на основе вашего примера Я применил указанное исправление в beforecheckchange. –

0

Основываясь на ответе Guiherme lopes, я применил исправление в beforecheckchange.

beforecheckchange: function(me , rowIndex , checked , record , e , eOpts){ 
      if(!Ext.fly(e.getTarget()).hasCls('x-grid-checkcolumn')){ 
       return false; 
      } 
      return true; 
     }