PDA

View Full Version : Grid - checkbox selection - can not select any rows programmatically



BostonMerlin
3 Jul 2013, 3:50 AM
Using Extjs 4.2.1 with latest Sencha architect.

I configured a simple grid with a checkbox selection model. run app, grid shows ten rows, all with a checkbox and two columns. perfect.

Now I want to programmatically select a few rows so I tried the following with associated results:



var grid = this.down('featuresGrid'); //console.dir(grid) returns the grid fine

grid.getSelectionModel.select(4); //no rows checked or highlighted
grid.getSelectionModel().select(2, true); // no errors, nothing checked or selected.
grid.getSelectionModel().selectAll(); // error: cannot call 'getRange' of undefined.
grid.getSelectionModel().select(features); //array of grid models. nothing checked.
grid.getView().getSelectionModel.select(3); //saw this online, nothing checked\

grid.getSelectionModel().setSelectionMode('MULTI'); //architect already defaults to 'MULTI' but tried anyways, did not change the above results.



I'm at a standstill. I've read the docs up and down. Googled everything I could think of and tried crazy alternatives to select one or more rows or just check those boxes off, no joy. I changed from a checkbox selection model to a row selection model, no difference.

Something is up with that selectAll method returning error so i'm guessing I have something misconfigured but I don't see the problem.

I'm open to any suggestions.

Thanks,
John



GRID


xtype: 'gridpanel',
itemId: 'featuresGrid',
title: 'My Grid Panel',
store: 'Options',
columns: [
{
xtype: 'gridcolumn',
dataIndex: 'Name',
text: 'String'
},
{
xtype: 'gridcolumn',
dataIndex: 'Description',
text: 'String'
}
],
selModel: Ext.create('Ext.selection.CheckboxModel', {

})


MODEL


{
name: 'OptionID',
type: 'int'
},
{
name: 'Name',
type: 'string'
},
{
name: 'Description',
type: 'string'
}


JSON SAMPLE, TEN MORE ROWS RETURNED


[{
"OptionID":3,
"Name":"Conference Details",
"Category":"Main Menu",
"Type":"Feature",
"Description":"Registration, Attire, Activity Desk etc."
}]

BostonMerlin
3 Jul 2013, 4:16 AM
resolved the issue. my issue was caused by the timing of the store load.

- created grid
- did a store load
- tried selecting records
- store finished loading.. argh.


all beter.