hbulens
hbulens

Reputation: 1969

Sencha ExtJS grid checkbox model single mode deselect

I was wondering if it is possible to deselect a selected row in a ExtJS 6 grid with this selModel configuration:

selModel: Ext.create('Ext.selection.CheckboxModel', {
            mode: 'SINGLE',
            checkOnly: 'true',
            allowDeselect: true,                              
 }),

I've got the following fiddle which shows the behavior I am currently facing: https://fiddle.sencha.com/#fiddle/1h4l

It looks like the only way to deselect a row is by selecting another row, which is not what I need.

Upvotes: 3

Views: 6225

Answers (2)

Robert Watkins
Robert Watkins

Reputation: 2206

Don't directly create the selection model; use the xtype instead. Changing the selModel to this works as expected in your fiddle:

selModel: { 
  selType: 'checkboxmodel',
  mode: 'SINGLE',
  checkOnly: 'true',
  allowDeselect: true               
},

Upvotes: 2

Chandra Sekar
Chandra Sekar

Reputation: 312

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

If you remove the mode:'SINGLE' then it works fine.

If you want to select one row at a time then you should check in the "beforeselect" event if any other row is selected or not.

You can get the number of checked ones by using:

var selectedRows = getSelectionModel().getSelection();

Upvotes: 0

Related Questions