Results 1 to 2 of 2

Thread: Missing hasMany associations sending data back to server

  1. #1
    Ext JS Premium Member
    Join Date
    Jan 2010
    Location
    Italy
    Posts
    44

    Default Missing hasMany associations sending data back to server

    Hi all,
    I'm trying to implement REST client that manage CRUD operations with nested JSON model.
    Everything il loaded correctly, I can see the store with the associated records.
    When I made some change to the data and sync() the nested data are missing from the output JSON.
    Below my implementation:

    Code:
    Ext.define('zeroClickProv.model.llfCircuit', {
        extend: 'Ext.data.Model',
    
        requires: [
            'Ext.data.field.Field'
        ],
    
        fields: [
            {
                name: 'Label'
            },
            {
                name: 'LosToCircuit'
            },
            {
                name: 'InsertionMode'
            }
        ]
    });
    
    Ext.define('zeroClickProv.model.llfBase', {
        extend: 'Ext.data.Model',
    
        requires: [
            'Ext.data.field.Field'
        ],
    
        hasMany: {
            model: 'zeroClickProv.model.llfCircuit',
            name: 'Circuits',
            associationKey: 'Circuits'
        },
    
        fields: [
            {
                name: 'id'
            },
            {
                name: 'EthPhysName'
            },
            {
                name: 'Status'
            },
            {
                name: 'AlarmToCircuit'
            },
            {
                name: 'Delay'
            },
            {
                name: 'ProtMode'
            }
        ]
    });
    
    Ext.define('zeroClickProv.view.cardLlfViewModel', {
        extend: 'Ext.app.ViewModel',
        alias: 'viewmodel.cardllf',
    
        requires: [
            'Ext.data.Store',
            'Ext.data.proxy.Rest',
            'Ext.data.reader.Json',
            'Ext.data.writer.Json'
        ],
    
        stores: {
            data: {
                autoLoad: false,
                autoSync: true,
                model: 'zeroClickProv.model.llfBase',
                listeners: {
                    load: 'onJsonstoreLoad'
                },
                proxy: {
                    type: 'rest',
                    url: 'http://MyRestService',
                    headers: {
                        accept: 'application/json'
                    },
                    reader: {
                        type: 'json'
                    },
                    writer: {
                        type: 'json',
                        writeAllFields: true  //I need that all data will be send back to server
                    }
                }
            }
        }
    
    });
    Data loaded
    Code:
    [
        {
            "id": 151,
            "Circuits": [
                {
                    "Label": "circ 1",
                    "LosToCircuit": 1,
                    "InsertionMode": 1
                },
                {
                    "Label": "circ 2",
                    "LosToCircuit": 1,
                    "InsertionMode": 0
                }
            ],
            "EthPhysName": "test",
            "Status": 1,
            "AlarmToCircuit": 1,
            "Delay": 3,
            "ProtMode": 0
        }
    ]
    After some changes this is sent to the server when sync()
    Code:
    {
        "id": 151,
        "EthPhysName": "test",
        "Status": 2,
        "AlarmToCircuit": 2,
        "Delay": 4,
        "ProtMode": 0
    }
    Circuits are gone...

    Probably I'm missing some key option or a bad approach to the use case
    Thanks in advance to any help

  2. #2
    Ext JS Premium Member
    Join Date
    Jan 2010
    Location
    Italy
    Posts
    44

    Default

    Bump Can anyone from the sencha dev team please take a look at this issue or anyone who has any input. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •