PDA

View Full Version : Hide checkbox in CheckboxSelectionModel



anpegar
18 Feb 2011, 3:27 AM
Hi folks, I have the following question.


24737

I build a grid using CheckboxSelectionModel but I want show the checkbox if the value of record.get('myColum') == 1, it's possible?

I have read to do override the renderer but I don't know do it.
The next code show the checkbox image when record.get('myColum') == 1 but the grid don't work when I push the header checkbox.



Ext.grid.CheckboxSelectionModel.override({
renderer: function (v, p, record){
if (record.get('myColum') == 0){
return '';
}else{
return '<div class="x-grid3-hd-checker">&#160;</div>';
}
}
});


Thanks in advance.

anpegar
20 Feb 2011, 11:23 PM
Hi, any idea?
Thank's

aramaki
21 Feb 2011, 12:56 AM
may be this one example:


if(grid.getStore().getAt(index).get('columnName') == 1){
grid.getColumnModel().setHidden(0,true);
}

anpegar
21 Feb 2011, 2:56 AM
aramaki, thank you for your reply but this sentence Ext.getCmp('GridAnexos').getColumnModel().setHidden(0,true); it's to hide all checkbox of the column "0" and I want to hide only the checkbox in some rows.

anpegar
21 Feb 2011, 3:50 AM
Hi, I used this solution and works fine but now when I click in the header checkbox all rows are selected, how I can avoid it? (look at the attachments)



var chkSM = new Ext.ux.CheckboxSelectionModel({
renderer: function (v, p, record){
if(record.data.PDTM_TIPO == 'ANEXO'){
p.css = 'noselect';
return Ext.grid.CheckboxSelectionModel.prototype.renderer.call(this, v, p, record);
}
}
});


24773

Thanks in advanced.

Condor
21 Feb 2011, 4:35 AM
Example (http://www.sencha.com/forum/showthread.php?122010-conditional-checking-on-Check-All&p=564122&viewfull=1#post564122)

Don't forget that removing the checkbox doesn't make the row unselectable. For that you also need to write a beforerowselect event handler that returns false for these records.

anpegar
21 Feb 2011, 4:48 AM
Thanks for your answers, finally I used this solution:
I don't know if this is the most appropriate solution but it seems simpler than the override the selectAll() method.

........
<script>
function checkRow(sm,index,record){
var vTipo = record.get('PDTM_TIPO');
if (vTipo == "NOTA"){
sm.deselectRow(index);
}
}

Ext.onReady(function(){

var chkSM = new Ext.ux.CheckboxSelectionModel({
renderer: function (v, p, record){
if(record.data.PDTM_TIPO == 'ANEXO'){
p.css = 'noselect';
return Ext.grid.CheckboxSelectionModel.prototype.renderer.call(this, v, p, record);
}
}
});

chkSM.on('rowselect', checkRow);
}); //end onReady

</script>

Thank for all.