1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    59
    Answers
    6
    Vote Rating
    0
    1099511627776 is on a distinguished road

      0  

    Default Unanswered: model doest not recognize more than 2 associations

    Unanswered: model doest not recognize more than 2 associations


    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:
    Code:
    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:
    Code:
    Ext.define('ASV.model.docheader',{
        extend: 'Ext.data.Model',
        fields:['name','value']
    });
    docbody:
    Code:
    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:
    Code:
    Ext.define('ASV.model.links',{
        extend: 'Ext.data.Model',
        fields:['name','value']
    });
    JSON response for document request is :
    Code:
    {
        "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
    }

  2. #2
    Sencha User
    Join Date
    Jul 2011
    Posts
    48
    Vote Rating
    1
    dcoan604 is on a distinguished road

      0  

    Default


    I thinks have a typo. In your associations, you named it "llinks" instead of "links"

  3. #3
    Sencha User
    Join Date
    Dec 2011
    Posts
    59
    Answers
    6
    Vote Rating
    0
    1099511627776 is on a distinguished road

      0  

    Default


    Sorry it was my mistake, I've forgot to add 'links' model to controller

Thread Participants: 1