View Full Version : Setting Checkboxes on GridPanel + CheckBoxModel

29 Dec 2011, 2:40 PM

This is part 2 to the post I previously made. While that post was answered, the solution does not work. I marked it as answered because the proposed solution looked reasonable.

The problem: On page load, set the checkboxes on a GridPanel to checked/unchecked based on a record field.

The solution: After the page is rendered and the store loaded, iterate over the records and set the checkboxes to match. I refactored the solution code to this:

var sm = grid.getSelectionModel();
var range = store.getRange();
var selectedRecords = [];

for (var i = 0; i < range.length; i++) {
if (range[i].get('Checked') == true) {

sm.select(selectedRecords, false, false);

When I run the original solution code or my code, the error message is the same:

Uncaught TypeError: Cannot read property 'parentNode' of undefined

This appears to be a bug in the SDK. Does anybody have any insight?

30 Dec 2011, 8:43 AM
What version are you using? This seems like a bug but want to test it out first.

Also, instead of using getRange and then iterating through that array you can use store.each(function(record) {});

30 Dec 2011, 8:46 AM
I tried this with both 4.0.2a and 4.0.7 and get the same error.

30 Dec 2011, 8:55 AM
Hmm... tried it with local data and remote data with 4.0.2a and 4.0.7 and cannot get an error.

30 Dec 2011, 12:41 PM
I put this code in the store.onLoad event handler in my controller. I presume this is happening after the widget has rendered. Since I cannot add a store event listener in the controller's this.control() method, I added store.on('load',fn) after the this.control(); Is that the right way to manage store events in the controller or is there a more elegant way?