PDA

View Full Version : Dont want to show checkbox in header for CheckboxSelectionModel



amanind
29 Mar 2011, 6:53 AM
Hi

I am using CheckboxSelectionModel to display checkbox in column of the grid. I don't want to show checkbox in header of the grid. In place that i want to show some label.

How to do this?

fay
29 Mar 2011, 7:34 AM
var sm = new Ext.grid.CheckboxSelectionModel({header: ''});


See: http://dev.sencha.com/deploy/dev/docs/?class=Ext.grid.CheckboxSelectionModel&member=header

amanind
29 Mar 2011, 9:15 PM
Fay, thanks for help

Can you tell me how to show checkbox checked when it renders based on some condition in grid?

fay
30 Mar 2011, 2:41 AM
Coincidentally this was asked this morning: http://www.sencha.com/forum/showthread.php?128047-pre-selection-grid-checkbox&p=585714&viewfull=1#post585714

Add a viewready listener to your grid:



var grid = new Ext.grid.GridPanel({
// ...
listeners: {
'viewready': function(grid)
{
var rows = [];
// Whatever logic you're using to determine what rows/records are selected.
rows[rows.length] = 0;
rows[rows.length] = 3;

grid.getSelectionModel().selectRows(rows, true);
}
});


See also the selectRecords and selectRows methods in http://dev.sencha.com/deploy/dev/docs/?class=Ext.grid.CheckboxSelectionModel:

amanind
30 Mar 2011, 3:20 AM
Fay, my grid load empty in starting and data load only when user click on search button.
In this case Listeners doesn't work when data loads.

Do i have to change event of listener from "viewready" to ??

fay
30 Mar 2011, 3:45 AM
Use the store's load (http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.Store) handler:



store.on('load', function(store, records, options)
{
var rows = [];

// Whatever logic you're using to determine what rows/records are selected.
rows[rows.length] = 0;
rows[rows.length] = 3;

grid.getSelectionModel().selectRows(rows, true);
grid.getView().refresh(); // Double-check whether you need this or not?
});

amanind
31 Mar 2011, 5:11 AM
Hey Fay,

Thanks for your solutions, it works
Can you help me on this thread also
.sen........ showthread.php?94126-New-approach-to-a-tree-grid-component&p=584300#post584300

fay
31 Mar 2011, 5:32 AM
Hey Fay,

Thanks for your solutions, it works
Can you help me on this thread also
.sen........ showthread.php?94126-New-approach-to-a-tree-grid-component&p=584300#post584300

Sorry I've never used that.

kim88
15 Sep 2011, 4:04 AM
I just want to say thank you for the information.
It is very valuable for me..newbie here and encountering the same situation.
Thanks and keep up the good work..

Travel Guide (http://arbitrosdecostarica.com/)