PDA

View Full Version : CheckboxSelectionModel, prevent rowselect from firing?!



callipigia
26 Aug 2010, 11:45 PM
I need to programmatically select records in a grid holding a CheckboxSelectionModel.
To do that I use the

selectRecords

method of CheckboxSelectionModel.

I also want selection model to not fire rowselect event. I tried to use suspendEvents and resumeEvents paradigma but it doesnt't work. I also tried to lock/unlock selections but it hasn't effect at all.

here is the code which programmatically select records



this.updateCheckSelection = function() {
if (!this.checkMode || !this.rendered)
return;
var sel = this.getCheckStore().getRange();
var sm = this.getSelectionModel();
var rs = new Array();
var store = this.getStore();
for (var i=0; i<sel.length; i++) {
var r = store.getById(sel[i].get(this.checkField));
if (!r) {
var idx = store.findExact(store.reader.meta.idProperty, sel[i].get(this.checkField));
if (idx >= 0) {
r = store.getAt(idx);
}
}
if (r) {
rs.push(r);
}
}
sm.suspendEvents();
sm.selectRecords(rs, false);
sm.resumeEvents();
}


The rowselect event handler updates a store; but it has to do it when events originate from a click on a checkbox and not when updateSelection is called. The only solution I came to after many tries is to give up with rowselect/deselect events and relay to cellclick event, though I don't like it very much...

regards

Ash2009
31 Aug 2010, 7:52 PM
there is a config "checkOnly" in checkboxSelectionModel , which basically selects the row only if the checkbox is checked.
I am not sure if that will prevent the rowselect event too but you can try this out.