PDA

View Full Version : Having issues selecting a title's in grid using getSelectionModel().getSelections()



Yemi
14 Feb 2014, 5:56 AM
I get this error message from the console when at the line colored red, not sure what the issue is:
Uncaught TypeError: Object function (b){var a=this.indexOf(b);if(a!=-1){this.splice(a,1)}return this} has no method 'get'

var grid = Ext.getCmp(id);
var records = grid.getSelectionModel().getSelections();
var ids= new Array();
if(records){
for (var i in records){
var rec = records[i];
if(rec.get('title')){

ids.push(rec.get('title'));
}
}
}

Gary Schlosberg
14 Feb 2014, 3:21 PM
In which specific version of ExtJS are you seeing this error message?

Yemi
14 Feb 2014, 3:51 PM
version 3.3, the interesting thing is that, when i do a console.log of the selected record i.e. the line in red, I get the output printed out to the browser console, even though I am still getting this error. I have also used this technique to retrieve record field columns on a grid in the past and it works fine. Not sure what is wrong here

Yemi
17 Feb 2014, 1:53 AM
Can anyone help with this please ?

Gary Schlosberg
18 Feb 2014, 9:22 AM
I think the issue is the way you are iterating through the array of selected records, which can include methods. You can try something like this:


var grid = Ext.getCmp(id);
var records = grid.getSelectionModel().getSelections();
var ids = new Array();
if (records) {
for (var i = 0; i < records.length; i++) {
var rec = records[i];
if (rec.get('title')) {
ids.push(rec.get('title'));
}
}
}

Yemi
18 Feb 2014, 11:48 PM
yes thats the issue, dont know why the former is not working though.

thanks