PDA

View Full Version : check all checkboxs by default in all rows in grid



amanind
17 Aug 2010, 1:50 AM
Hi

I am using

var sm = new Ext.grid.CheckboxSelectionModel(); to display checkbox in grid and i want all the checkboxes to be checked onload of grid. which property have to set to do this

Condor
17 Aug 2010, 3:14 AM
grid.on('viewready', function(){
grid.getSelectionModel().selectAll();
});
Or are you loading the store after the grid is created? In that case you should use the store 'load' event for this.

amanind
17 Aug 2010, 3:27 AM
I am doing it like this

grid2.getStore().loadData(data);
grid2.getSelectionModel().selectAll();
Is this right way?

One more thing, if I have to clear grid, what method should I use, I am using
grid2.removeAll();
but it is not working

Animal
17 Aug 2010, 3:57 AM
Grid is backed by the Store. You know you have to load it....

amanind
17 Aug 2010, 4:30 AM
which method should i use to clear all values in grid

Condor
17 Aug 2010, 4:42 AM
Animal already gave you a hint: You don't clear the grid - you clear the store.

amanind
17 Aug 2010, 4:45 AM
Ok sorry, got it now, thanks both for you

amanind
19 Aug 2010, 7:47 AM
Condor,

1. when All checkboxs are checked, I want header checkbox should also checked, how to do that?

2. And on click on row, checkbox should not be check or uncheck

Condor
19 Aug 2010, 7:59 AM
You want things a standard CheckboxSelectionModel can't do. There is an extended CheckboxSelectionModel in the User Extensions forum that can do this.

amanind
19 Aug 2010, 8:07 AM
what should I use in place of
var sm = new Ext.grid.CheckboxSelectionModel();

amanind
19 Aug 2010, 11:47 PM
Can I override rowclick function in grid? if yes how

amanind
20 Aug 2010, 12:02 AM
How to change the value of grid header at runtime

Condor
20 Aug 2010, 12:18 AM
How to change the value of grid header at runtime


function setCheckboxSelectionHeader(grid, checked) {
var index = grid.getColumnModel().getIndexbyId('checker');
var checkbox = Ext.fly(grid.getView().getHeaderCell(index).firstChild);
checkbox[checked ? 'addClass' : 'removeClass']('x-grid3-hd-checker-on');
}

Condor
20 Aug 2010, 12:19 AM
Can I override rowclick function in grid? if yes how

To get a CheckboxSelectionModel to ignore row selection will require patching CheckboxSelectionModel.handleMouseDown.

amanind
20 Aug 2010, 1:37 AM
Thanks alot this works to disable rowclick and columnclick
var sm = new Ext.grid.CheckboxSelectionModel({ handleMouseDown: Ext.emptyFn });