You found a bug! We've classified it as
EXTJS-23680
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
-
Sencha User
argument of onSelectionStoreClear is wrong in Ext.mixin.Selectable
ExtJs Version:
ExtJs 6.0.2.437
Test case:
https://fiddle.sencha.com/#fiddle/1eka
Bug Description:
A multiple-selection list(mode: 'MULTI'),
1. select several records, for example, I select 3 records
2. call list.getSelectionCount(), it returns 3
3. call store.removeAll()
4. call list.getSelectionCount() again, it not 0 but still 3
Reason:
Code:
onSelectionStoreRemove: function(store, records) {
var me = this,
selected = me.selected,
ln = records.length,
removed, record, i;
if (me.getDisableSelection()) {
return;
}
for (i = 0; i < ln; i++) {
record = records[i];
if (selected.remove(record)) {
if (me.getLastSelected() == record) {
me.setLastSelected(null);
}
if (me.getLastFocused() == record) {
me.setLastFocused(null);
}
removed = removed || [];
removed.push(record);
}
}
if (removed) {
me.fireSelectionChange([
removed
]);
}
},
onSelectionStoreClear: function(store) {
var records = store.getData().items;
this.onSelectionStoreRemove(store, records); //arguments 'records' should be the removed records, not the records left in the store
}
The code above is a piece of class 'Ext.mixin.Selectable'.
The arguments 'records' of 'onSelectionStoreClear' should be the removed records, not the records left in the store, or it will not trigger the 'fireSelectionChange' inside 'onSelectionStoreRemove'
Workaround:
Override the 'onSelectionStoreClear' function of dataview.
Code:
Ext.define('Ext.overrides.dataview.DataView', {
override: 'Ext.dataview.DataView',
onSelectionStoreClear: function(store, records) {
this.onSelectionStoreRemove(store, records); //arguments 'records' should be the removed records, not the records left in the store
}
});
-
Sencha User
Thanks for the report! I have opened a bug in our bug tracker.