PDA

View Full Version : [CLOSED] GridPanel Deselect Issue



iansriley
May 22, 2014, 4:30 PM
Hi,

We are using Ext.net2.5 version, will having an issue with GridPanel deselect row that is
1. grid row needs to deselect When CTRL+ Select Row
OR
2. I have set the AllowDeselect="true" to RowSelectionModel then Grid row is deselecting on single click only but not CTRL+Select row.
Please help me in this ,However this is used to CTRL+Select Row in EXt.net 1.x version

Daniil
May 22, 2014, 4:56 PM
Hi @iansriley,

Please set up Mode="Multi" for the SelectionModel. Then it should be the same as it is in v1.

iansriley
May 22, 2014, 6:14 PM
Hi,
Thanks for the solution it is working when set Mode="Multi" , But we should not allow user to select multiple rows.

Thanks in advance.

Daniil
May 23, 2014, 4:58 AM
Got it. So, to have the same behavior in v I can suggest to use AllowDeselect="true" and this override.

Ext.selection.Model.override({
selectWithEvent: function (record, e) {
var me = this,
isSelected = me.isSelected(record),
shift = e.shiftKey,
ctrl = e.ctrlKey,
start = me.selectionStart,
selected = me.getSelection(),
len = selected.length,
allowDeselect = me.allowDeselect,
toDeselect, i, item;

switch (me.selectionMode) {
case 'MULTI':
if (shift && start) {
me.selectRange(start, record, ctrl);
} else if (ctrl && isSelected) {
me.doDeselect(record, false);
} else if (ctrl) {
me.doSelect(record, true, false);
} else if (isSelected && !shift && !ctrl && len > 1) {
toDeselect = [];

for (i = 0; i < len; ++i) {
item = selected[i];
if (item !== record) {
toDeselect.push(item);
}
}

me.doDeselect(toDeselect);
} else if (!isSelected) {
me.doSelect(record, false);
}
break;
case 'SIMPLE':
if (isSelected) {
me.doDeselect(record);
} else {
me.doSelect(record, true);
}
break;
case 'SINGLE':
if (allowDeselect && !ctrl) {
allowDeselect = me.toggleOnClick;
}
if (allowDeselect && isSelected && ctrl) { // the only change - added "&& ctrl"
me.doDeselect(record);
} else {
me.doSelect(record, false);
}
break;
}

if (!shift) {
if (me.isSelected(record)) {
me.selectionStart = record;
} else {
me.selectionStart = null;
}
}
}
});