PDA

View Full Version : Using SelectionModel in the GridPanel



neurodon
18 Oct 2012, 7:19 AM
Hello,

I have a GridPanel that loads it's records from a store. My goal is to select a row that matches a field/value pair in the store on the on the initialization of the GridPanel.

Here is the code that runs in the 'viewready' event of the grid panel:


viewready: function(me,opts) {
var record = me.getStore().findRecord('objectid',this.objectid);
me.getSelectionModel().select(record);
}



The issue I am having is that for some reason, getSelectionModel() is not binding to the store properly. If I output the result of me.getSelectionModel().getCount()... it displays '0' even though I have 11 records in the store.

What do I need to do to make this work?

Thanks in advance,

B

neurodon
18 Oct 2012, 9:07 AM
I figured out how to highlight the row... it was easier to do it with the GridView.

Here is my code in the GridPanel:


viewConfig: {
loadMask:false,
getRowClass: function(record, rowIndex, rowParams, store){
if(this.highlightObjectID!=undefined) {
return record.get("objectid")==this.highlightObjectID ? "object-selected" : "";
}
return "";
}
}


The SelectionModel still does not work however.

neurodon
18 Oct 2012, 9:59 AM
I figured out what the issue was on the getSelectionModel() problem. getCount() returns the number of selected rows, not the total number of rows.