简体   繁体   中英

select row only when checkbox is clicked ExtjS 4

In an ExtJS 4.1 grid that uses CheckboxModel as a selection model, when you click on an entire row, that row is selected (and the corresponding checkbox is checked). Is there a way that I can prevent that default behaviour from happening and permit row selection only when the checkbox for a corresponding row is clicked (as opposed to when clicking the entire row)?

Again I'm using ExtJS version 4.1

Thanks for any help

Note: My grid also has the CellEditing plugin attached to it. I don't want the row to be selected when the CellEditing plugin gets activated when I click on a cell.

Try the checkOnly property on your CheckBoxModel:

var sm = new Ext.selection.CheckboxModel({
    checkOnly: true
});

From the documentation:

http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.selection.CheckboxModel-cfg-checkOnly

checkOnly : Boolean

True if rows can only be selected by clicking on the checkbox column.

Defaults to: false

Please see my fiddle here for a working example: https://fiddle.sencha.com/#fiddle/vue

Update

To change the CheckBoxModel checkOnly mode after the grid has been rendered:

grid.getSelectionModel().checkOnly = true;

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