PDA

View Full Version : Load record into Form



BoerbooM
26 Apr 2012, 4:26 AM
I have been searching for a few days now but I can not seem to find the solution.. :-/

By looking at the example MVC application (http://docs.sencha.com/ext-js/4-0/#!/guide/application_architecture) I have created a grid and a form.
I have been able to load a record directly from the grid into the form using the following code;


editCourse:function(grid, record){
var form = Ext.ComponentQuery.query("viewport #PanelCourseEdit")[0];
form.loadRecord(record);

var panel = Ext.ComponentQuery.query("viewport #MainPanel")[0];
panel.getLayout().setActiveItem(1);
},



I would like to (re)load the data to be sure it has not been changed by someone else.
There for I tried to load the record in the Model and put it in the form.
Trying the following does not work;


var CourseModel = Ext.ModelManager.getModel("CourseManager.model.Course");
CourseModel.load(record.data.Id, {
success:function(new_record){
form.loadRecord(new_record);
}
});

I keep getting the following error:

Uncaught TypeError: Cannot call method 'indexOf' of undefined ext-all-debug.js:5301

Any help and/or point me in the right direction is highly appreciated.

vietits
26 Apr 2012, 5:50 AM
Do you define a proxy for your model?