PDA

View Full Version : Setting Checkboxes on GridPanel + CheckBoxModel



billtricarico
28 Dec 2011, 4:54 PM
Hello,

I have a GridPanel with the CheckBoxModel plugin working as I pull records from a store. I have a hidden 'checked' field in the model that I want to use to manage state for these records. That is working too.

When the page loads, I want the checkboxes on the CheckBoxModel to read the store records' 'checked' field and set their checked/unchecked state appropriately.

How can this be done?

Thanks.

Farish
29 Dec 2011, 1:35 AM
As far as I understand, the CheckBoxModel is for selection/deselection of rows in a grid. This would mean that the checkbox is checked when a row is selected and unchecked for the not-selected rows. If what you want is to select the rows, then you can iterate over the store records and select those entries in the grid:


for(var i=0; i<store.getRange().length; i++)
{
if(store.getRange()[i].get('checked') == 1)
grid.getSelectionModel().select(store.getRange()[i]);
}

Let me know if this is what you wanted and if it works.

Regards,
Farish

billtricarico
29 Dec 2011, 8:28 AM
Yes that was my fallback way to get this done. I was hoping there was a way to bind the store to the selection model. Thanks.

billtricarico
29 Dec 2011, 10:21 AM
Unfortunately this code is not working. The selectionModel.select() method throws an error:


Uncaught TypeError: Cannot read property 'parentNode' of undefined

Farish
29 Dec 2011, 11:42 PM
If you could post the relevant part of the code, may be I or someone else can suggest something.

Regards,
Farish