PDA

View Full Version : complex models



hulek89
2 Feb 2011, 6:02 AM
[[{"Name":"xxxx","Reason":"yyyyy","Tooltip":"zzzzzzz,"Percentage":10.00},....], [{"Name":"xxxx","Reason":"yyyyy","Tooltip":"zzzzzzz,"Percentage":10.00},....]]


i need a model for something like this; i tried


Ext.regModel('DeclinationReasonsList', {
hasMany: 'DeclinationReasonsItems'
});

Ext.regModel('DeclinationReasonsItems', {
hasMany: 'DeclinationReasonsItem'
});

Ext.regModel('DeclinationReasonsItem', {
fields: [
{ name: 'Name', type: 'string' },
{ name: 'Reason', type: 'string' },
{ name: 'Precentage', type: 'int' },
{ name: 'Tooltip', type: 'string' }
]
});



with no success. any help apreciated

ethan.zhang@sap.com
3 Jul 2012, 1:28 AM
any luck? have you solve your complex model problem? I need to design a similar model and wondering how to.

hulek89
3 Jul 2012, 2:32 AM
In sencha 2 the models have been improved. Short example


Ext.define('ListItem', {
extend: 'Ext.data.Model',
config: {
fields: [{ name: 'Id', type: 'int' }, { name: 'Text', type: 'string' }, { name: 'leaf', mapping: 'Leaf', type: 'bool'}],
hasMany: [{ name: 'Items', model: 'ListItem'}]
}
});


Ext.define('DocumentItem', {
extend: 'Ext.data.Model',
config: {
fields: [{ name: 'DocId', type: 'int' },
{ name: 'Text', type: 'string' },
{ name: 'Title', type: 'string' },
{ name: 'SubTitle', type: 'string' },
{ name: 'PublishedDate', type: 'string' },
{ name: 'SubmittedDate', type: 'string'}]
}
});


The first one is designed for Nested list component, whereas the latter is just a simple model. Both work well.

If you have further problems post some code you want to make work.

Hope that helps