简体   繁体   中英

EXTJS 5 : How to have the checkbox selected only when clicking on checkbox in grid

Could you please let me know how to have the row selected in the grid only when clicking on the checkbox and not when clicking on any other cell in the grid.

I also tried to override the same using the below code but was unable to achieve the desired result.....

Ext.CheckboxSelectionModel = Ext.extend(Ext.selection.CheckboxModel, {
beforeselect: function (grid, record, index, eOpts) {
}
});

最终...在没有进行相同的适当调整/修改之后。.我在extjs论坛中发布了相同的内容,然后将其标记为将在v5.0.2中修复的错误。 sencha.com/forum/showthread.php?291021-EXTJS-5-如何在单击网格中的复选框时仅选择复选框&p = 1063513#post1063513

this is a ExtJS 5 bug

its work easily

selModel : Ext.create('Ext.selection.CheckboxModel', {
    checkOnly: true,
});

but only in ExtJS 5.0.2 its fixed

proof: http://www.sencha.com/forum/showthread.php?290630

One way of doing that would be is to listen for cellClick event and check if cellIndex matches your checkbox cell index. Use selectionModel. deselect /deselectAll if cellClick doesn't match.

cellclick: function (thisRef, td, cellIndex, record, tr, rowIndex, e, eOpts){
    if (cellIndex !== 0){ //Considering index 0 is checkbox column
        thisRef.selModel.deselect(record);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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