PDA

View Full Version : CheckboxSelectionModel



manniPulation
12 Dec 2007, 1:56 AM
is it possible to disable the checkbox of a row depending on a value in that row? for example in a productlist the selection of an item should not be possible when it is out of stock.
do i have to override CheckboxSelectionModel() or is there an other way. Thanks for any good hint. regards....

sugen
12 Dec 2007, 2:25 AM
我也被这个问题闹心了很久了..一直没有解决...希望有哪位仁兄帮下忙...谢谢:)

BigTitus
17 Jan 2008, 1:28 AM
Has anyone found a solution on this? :s

gascencao
8 Feb 2008, 10:21 AM
I ran into the same problem, and I found a way to do it.


Ext.grid.MyCheckboxSelectionModel = function(config){
Ext.apply(this, config);

this.disabledRows = new Ext.util.MixedCollection(false, function(o){
return o.id;
});

Ext.grid.MyCheckboxSelectionModel.superclass.constructor.call(this);

};

Ext.extend(Ext.grid.MyCheckboxSelectionModel, Ext.grid.CheckboxSelectionModel, {

// private
initEvents : function(){
Ext.grid.MyCheckboxSelectionModel.superclass.initEvents.call(this);
this.on("beforerowselect", function(sm, index, keepExisting, r) {
return !(sm.disabledRows.key(r.id));
}, this);
},

disableRow: function(index) {
if(this.locked || (index < 0 || index >= this.grid.store.getCount())) return;
var r = this.grid.store.getAt(index);
if(r){
this.disabledRows.add(r);
this.deselectRow(index);
this.grid.getView().getCell(index, 0).firstChild.firstChild.className = '';
}
},

enableRow: function() {
if(this.locked) return;
var r = this.grid.store.getAt(index);
if(r){
this.disabledRows.remove(r);
this.grid.getView().getCell(index, 0).firstChild.firstChild.className = 'x-grid3-hd-checker';
}
}

});


I hope you like it.

paulie
15 Feb 2008, 6:26 AM
I ran into the same problem, and I found a way to do it.


Ext.grid.MyCheckboxSelectionModel = function(config){
Ext.apply(this, config);

this.disabledRows = new Ext.util.MixedCollection(false, function(o){
return o.id;
});

Ext.grid.MyCheckboxSelectionModel.superclass.constructor.call(this);

};

Ext.extend(Ext.grid.MyCheckboxSelectionModel, Ext.grid.CheckboxSelectionModel, {

// private
initEvents : function(){
Ext.grid.MyCheckboxSelectionModel.superclass.initEvents.call(this);
this.on("beforerowselect", function(sm, index, keepExisting, r) {
return !(sm.disabledRows.key(r.id));
}, this);
},

disableRow: function(index) {
if(this.locked || (index < 0 || index >= this.grid.store.getCount())) return;
var r = this.grid.store.getAt(index);
if(r){
this.disabledRows.add(r);
this.deselectRow(index);
this.grid.getView().getCell(index, 0).firstChild.firstChild.className = '';
}
},

enableRow: function() {
if(this.locked) return;
var r = this.grid.store.getAt(index);
if(r){
this.disabledRows.remove(r);
this.grid.getView().getCell(index, 0).firstChild.firstChild.className = 'x-grid3-hd-checker';
}
}

});


I hope you like it.
Hi, thanks for sharing this.

Apologies for being so thick but can you provide an example of how I might use it.

I have a column called isLocked which is either true or false and determines whether the checkbox can be selected.

Do I have to pass the conditions in the config options?

Many Thanks for your time.

Best Wishes,

Paul