PDA

View Full Version : update model with json



aaron7744
21 Sep 2011, 10:50 PM
i have a model like:

Ext.define('ResultDetail', {
extend : 'Ext.data.Model',
fields : [ {
name : 'id',
type : 'int'
}, {
name : 'email',
type : 'string'
} ],
hasMany : [ {
model : 'Testresults',
name : 'testresultsbeans'
} ],
proxy : {
type : 'rest',
url : myurl
},
reader : {
type : 'rest',
root : 'resultDetailBean'
}
});
I can receive the Json-Data from sercer-side and i want to get the record value with:

var ResultDetail = Ext.ModelManager.getModel('ResultDetail');
ResultDetail.load(id,{
success: function(resultDetail,operation) {
var email = resultDetail.get("email");
......
}
});

But this dosent work. Can someone tell me, how to automatic update the model record and get the record value?

Thanks

mankz
22 Sep 2011, 12:33 AM
There is no 'rest' reader, try setting 'json' instead:


Ext.define('ResultDetail', {
extend : 'Ext.data.Model',
fields : [ {
name : 'id',
type : 'int'
}, {
name : 'email',
type : 'string'
} ],
hasMany : [ {
model : 'Testresults',
name : 'testresultsbeans'
} ],
proxy : {
type : 'rest',
url : myurl,
reader : {
type : 'json',
root : 'resultDetailBean'
}
}
});

aaron7744
22 Sep 2011, 1:12 AM
thank you for the advice. I 've changed the reader type.

But it still dosent work. :(

aaron7744
23 Sep 2011, 1:13 AM
any new idea ? :)

mankz
23 Sep 2011, 3:53 AM
could you repost your current code?

aaron7744
27 Sep 2011, 9:19 AM
i found the problem. Just add " format : 'json' "
Thank you for your help.