Results 1 to 3 of 3

Thread: Extjs 5.1.0 - (Issue) REST proxy adds extra data to the original record model

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

    Default Extjs 5.1.0 - (Issue) REST proxy adds extra data to the original record model

    Hi
    I found an issue using the REST proxy when I try to sync my store after a previous sync.
    Here is how is configured my data store and my proxy:
    Code:
    Ext.define('testRest.view.MyPanelViewModel', {
        extend: 'Ext.app.ViewModel',
        alias: 'viewmodel.mypanel',
    
        requires: [
            'Ext.data.Store',
            'Ext.data.proxy.Rest',
            'Ext.data.reader.Json',
            'Ext.data.writer.Json',
            'Ext.data.field.Field'
        ],
    
        stores: {
            data: {
                autoLoad: true,
                autoSync: true,
                proxy: {
                    type: 'rest',
                    url: 'http://localhost:8080/zeroclick-rest-service/users/1/templates/2151/roadmap/2152/eqparams/2157',
                    headers: {
                        accept: 'application/json'
                    },
                    appendId: false,
                    reader: {
                        type: 'json'
                    },
                    writer: {
                        type: 'json',
                        writeAllFields: true
                    }
                },
                fields: [
                    {
                        name: 'id'
                    },
                    {
                        name: 'AgentIp'
                    },
                    {
                        name: 'EquipLabel'
                    },
                    {
                        name: 'BridgeMode'
                    }
                ],
                listeners: {
                    load: 'onJsonstoreLoad',
                    write: 'onJsonstoreWrite'
                }
            }
        }
    
    });
    After the first data load, modifying the data and sync() the output is like that:
    restProxySync.jpg

    But after the client/server round trip inspecting the record data with console.log there are extra data added to the original model.

    firebugRest.jpg

    If I alter the data again when sync occur the system fall in "too many recursion" because I think is trying to encode the complex extra data.
    This is because I'm forced to use "writeAllFields: true"
    This extra data seems to be the response information attached by the writer or reader to my original record.
    Hope to be clear enough...
    Anyone have some advice.

    Thanks in advance

  2. #2
    Sencha - Sustaining Engineer tristan.lee's Avatar
    Join Date
    Mar 2015
    Location
    Central Ohio
    Posts
    1,579
    Answers
    165

    Default

    Are your listeners modifying the data at all? It looks like the request is being applied to the model.
    Tristan Lee
    Sencha Inc - Sustaining Engineer


    Having an issue? Help us help you - be detailed; provide some code; demonstrate with a fiddle (fiddle.sencha.com)

    Embed your fiddle in your post: [FIDDLE]id[/FIDDLE]

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

    Default

    Thanks for your reply...
    No the listeners does not modify the data, they simply puts the loaded data in the controls.
    As you can see in the first pic the data are not applied in the request but as in the second pic they appear after the response.
    Here is the code of the controller...

    Code:
    Ext.define('testRest.view.MyPanelViewController', {
        extend: 'Ext.app.ViewController',
        alias: 'controller.mypanel',
    
        onTextfieldBlur: function(component, event, eOpts) {
            this.getViewModel().getStore('data').getAt(0).set('EquipLabel',component.getValue());
        },
    
        onTextfieldBlur1: function(component, event, eOpts) {
            this.getViewModel().getStore('data').getAt(0).set('AgentIp',component.getValue());
    
        },
    
        onPanelAfterRender: function(component, eOpts) {
            this.getViewModel().getStore('data').load();
        },
    
        onNumberfieldBlur: function(component, event, eOpts) {
            this.getViewModel().getStore('data').getAt(0).set('BridgeMode',component.getValue());
    
        },
    
        onJsonstoreLoad: function(store, records, successful, eOpts) {
            this.getReferences().label.setValue(store.getAt(0).data.EquipLabel);
            this.getReferences().bridge.setValue(store.getAt(0).data.BridgeMode);
            this.getReferences().agent.setValue(store.getAt(0).data.AgentIp);
    
        },
    
        onJsonstoreWrite: function(store, operation, eOpts) {
            console.log(store.getAt(0).data); //log of the second pic
        }
    
    });

Similar Threads

  1. model.load('xxxxx') does not send ID, Rest Proxy
    By mysticav in forum Ext 5: Q&A
    Replies: 2
    Last Post: 12 Jun 2015, 12:04 PM
  2. Dynamic Assignment of Extra Parameters in REST Proxy
    By senchite01 in forum Sencha Touch 2.x: Q&A
    Replies: 5
    Last Post: 16 May 2012, 5:58 AM
  3. Replies: 2
    Last Post: 30 Apr 2012, 1:01 PM
  4. Replies: 6
    Last Post: 6 Feb 2012, 11:25 AM
  5. Model load with REST proxy and extra query parameters
    By jochenp in forum Sencha Touch 2.x: Q&A
    Replies: 1
    Last Post: 6 Feb 2012, 9:49 AM

Posting Permissions

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