PDA

View Full Version : model doest not recognize more than 2 associations



1099511627776
3 Mar 2012, 11:48 PM
Hellow world :)
Here is my problem:
I have a model 'document' with associated (hasmany) models 'docheader' and 'docbody'.
Thay worked fine for a while but than I've added another model 'links' which I cannot access through 'document' model. and I cannot firuge where is a problem.
The models look like this:
document:


Ext.define('ASV.model.document',{
extend: 'Ext.data.Model',
reqiures:[
'ASV.model.docheader',
'ASV.model.docbody',
'ASV.model.links'
],
fields:['id'],
associations:[{
type:'hasMany',
model:'ASV.model.docheader',
name:'header'
},{
type:'hasMany',
model:'ASV.model.docbody',
name:'body'
},{
type:'hasMany',
model:'ASV.model.links',
name:'llinks'
}]
});

docheader:


Ext.define('ASV.model.docheader',{
extend: 'Ext.data.Model',
fields:['name','value']
});

docbody:


Ext.define('ASV.model.docbody',{
extend: 'Ext.data.Model',
fields:[
{name: 'docrejid',type:'int'},
{name: 'docid',type:'int'},
{name: 'article',type:'string'},
{name: 'brand',type:'string'},
{name: 'name', type:'string'},
{name: 'quantity', type:'float'},
{name: 'price', type:'float'}
]
});

links:


Ext.define('ASV.model.links',{
extend: 'Ext.data.Model',
fields:['name','value']
});


JSON response for document request is :

{
"doc": {
"body": [
{
"docid": 78,
"name": null,
"brand": "CONTITECH",
"article": "CT1001",
"docrejid": 173,
"price": 157,
"quantity": 10
}
],
"header": [
{
"name": "docnumber",
"value": "ZP-20"
},
{
"name": "comment",
"value": null
},
{
"name": "docid",
"value": 78
},
{
"name": "summ",
"value": 1570
},
{
"name": "client",
"value": "ip-auto"
},
{
"name": "status",
"value": "????????"
},
{
"name": "date",
"value": "2012/01/15 16:50:34"
}
],
"id": "78",
"links": [
{
"name": "action",
"value": "outorders"
},
{
"name": "objtype",
"value": "document "
},
{
"name": "objlink",
"value": "client"
},
{
"name": "id",
"value": "kod"
},
{
"name": "caption",
"value": null
}
]
},
"success": true
}

dcoan604
4 Mar 2012, 11:05 AM
I thinks have a typo. In your associations, you named it "llinks" instead of "links"

1099511627776
5 Mar 2012, 12:19 AM
Sorry it was my mistake, I've forgot to add 'links' model to controller