After solving a few problems, at last I can see my view but I came across another problem: I can't save my data (model) into a store. Here is my code:
Code:
var currentUser= this.profileView.getRecord();
this.profileView.updateRecord(currentUser);
var errors = currentUser.validate();
if (!errors.isValid()) {
currentUser.reject();
Ext.Msg.alert('Wait!', errors.getByField('name')[0].message, Ext.emptyFn);
return;
}
// save user profile to data store
var store = this.getStore('App.store.MyProfile');
if (null == store.findRecord('id', currentUser.data.id)) {
store.add(currentUser);
} else {
currentUser.setDirty();
}
Almost the same code running in Sencha Touch 1.1 has no problem. But failed at Sencha Touch 2. The error message is:
Uncaught TypeError: Cannot call method 'create' of undefined
It's either in this.profileView.updateRecord(currentUser); or store.add(currentUser);. I checked the store and currentUser, they seems to be correct. What could be wrong? (My store's autoSync is set to true, so I think I don't need to call store.sync() after the store.add())
Thanks