basememara
5 Feb 2012, 10:34 AM
In my model, I am trying to make one of my properties a collection of a certain model, but Ext JS is not recognizing it as being the model. The reason I think this is because the custom properties from the child objects are not showing. It has the values from the proxy JSON request, but not the Ext JS custom property.
Here is my parent model:
Ext.define('MyApp.model.User', {
extend: 'Ext.data.Model',
fields: [
'FirstName',
{ name: 'Orders', type: 'Order' } //A COLLECTION OF ORDERS
]
});
This is my child model:
Ext.define('MyApp.model.Order', {
extend: 'Ext.data.Model',
fields: [
'ID',
'Description',
//CUSTOM PROPERTIES
{
name: 'ShortDescription',
convert: function(v, record) {
return Ext.util.Format.ellipsis(record.data.Description, 50);
}
},
]
});
Then in my template, I am trying to get the nested order object but nothing displays for {ShortDescription}, I can only render out real properties and not the constructed ones:
[tpl: = [
'<header><h1>{FirstName}</h1></header>',
'<ul>',
'<tpl for="Orders">',
'<li><a href="{ID}" tooltip="{Description}">{ShortDescription}</a></li>',
'</tpl>',
'</ul>'
]
For the above template, {ID} and {Description} gets rendered out, but {ShortDescription} is blank. I have orders on a different template where it is a first level or root object and {ShortDescription} gets rendered fine in that scenario. It is just when it is a child property of another object.
Anybody know what I am missing? I have also tried to use hasMany association, but didn't work. I think because my stores are memory readers, so I was hoping to handle this on the model level and not the store.
Here is my parent model:
Ext.define('MyApp.model.User', {
extend: 'Ext.data.Model',
fields: [
'FirstName',
{ name: 'Orders', type: 'Order' } //A COLLECTION OF ORDERS
]
});
This is my child model:
Ext.define('MyApp.model.Order', {
extend: 'Ext.data.Model',
fields: [
'ID',
'Description',
//CUSTOM PROPERTIES
{
name: 'ShortDescription',
convert: function(v, record) {
return Ext.util.Format.ellipsis(record.data.Description, 50);
}
},
]
});
Then in my template, I am trying to get the nested order object but nothing displays for {ShortDescription}, I can only render out real properties and not the constructed ones:
[tpl: = [
'<header><h1>{FirstName}</h1></header>',
'<ul>',
'<tpl for="Orders">',
'<li><a href="{ID}" tooltip="{Description}">{ShortDescription}</a></li>',
'</tpl>',
'</ul>'
]
For the above template, {ID} and {Description} gets rendered out, but {ShortDescription} is blank. I have orders on a different template where it is a first level or root object and {ShortDescription} gets rendered fine in that scenario. It is just when it is a child property of another object.
Anybody know what I am missing? I have also tried to use hasMany association, but didn't work. I think because my stores are memory readers, so I was hoping to handle this on the model level and not the store.