Check all checkbox in gridpanel in extjs

saili picture saili · Nov 16, 2010 · Viewed 13.2k times · Source

I would like to check all of the checkbox made by Ext.grid.CheckColumn in a gridpanel, may I know if there is any easy way to do this? I have try to add class to the checkbox(Ext.grid.CheckColumn) but it seem not work.

Thanks very much!

Answer

Joeri Sebrechts picture Joeri Sebrechts · Dec 31, 2011

If you're rendering a store field as a checbox column, you have to set that field to true for all the records in the store.

store.each(function(rec){ rec.set('field', true) })

Never try to change a grid cell's value directly, always change it via the store's corresponding record.

Update: if you have many records, use something like this:

store.suspendEvents(); // avoid view update after each row
store.each(function(rec){ rec.set('field', true) })
store.resumeEvents();
grid.getView().refresh();