PDA

View Full Version : Retrieving data from the Panel Grid in Controller



Tom400
12 Aug 2013, 6:17 AM
Hi, I have one small problem. I have created a controller and I would like to get the selection record from my Grid Panel. Im using for this purpose methods like:


var record = this.getView('List').getSelectionModel().getSelection()[0];



var record = this.getUserList().getSelectionModel().getSelection()[0];


In both cases I get the error that the function getSelectionModel() doesnt exists. This is my controller:


Ext.define("MyApp.controller.Users", {
extend: "Ext.app.Controller",

stores: ["Users"],
models: ["User"],
views: [ "List" ],

ref: [{
ref: "userlist",
selector: "userlist"
}],

init: function(){
this.control({
"userlist button[action=insert]" : {
click : this.insert
}
});
},

insert: function(){
var record = this.getView('List').getSelectionModel().getSelection()[0];
var record2 = this.getUserList().getSelectionModel().getSelection()[0];

console.log(record);
console.log(record2);
}
});



Can you just help me to solve this problem. Thanks a lot in advance!!!

Mthor
12 Aug 2013, 11:31 AM
you just need grid.getSelectionModel(), dont get from the view

also in the


ref: [{
ref: "userlist",
selector: "userlist"
}],

should be

ref: [{
ref: "userlist",
selector: "#userlist" // if that is the id of the item
}],

evant
12 Aug 2013, 8:01 PM
Your reference is incorrect:



var sm = this.getUserlist().getSelectionModel();