3
votes

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.

2
I looks like a bug. I would report it on the Sencha forum - the allowDeselect doesn't seem to have any effect.pagep
@pagep Thought so too. I'll submit the ticket right away.hbulens
@hbulens Yes I tried in many possible scenario to grid but allowDeselect does'nt make any effect in EXTJS 6, Its fine ExtJS 5. Its bug.UDID

2 Answers

2
votes

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               
},
0
votes
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();