Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read additional response data after syncing store

I have the following situation. I have a TreeStore that is synced with my server. The server response returns the modified node data with an additional property 'additionalTasks' (which stores some server-generated info for new nodes). How can I get this property's value if all of the store's listeners get already an instantiated record object and not the raw response data ? I've tried adding this additional field to my model, but when I check it's value for the records in the listener function they're shown as null.

    Ext.define('ExtendedTask', {
        extend: 'Ext.data.NodeInterface',
        fields: [
            { name : 'additionalData', type : 'auto', defaultValue : null, persist : false}
        ]
    });

var store = Ext.create("Ext.data.TreeStore", {
    model : 'ExtendedTask',
    autoSync: false,
    proxy : {
        method: 'GET',
        type : 'ajax',
        api: {
            read : 'tasks.js',
            update : 'update.php',
            create : 'update.php'
        },
        reader : {
            type : 'json'
        }
    },
    listeners: {
        update : function(){
            console.log('arguments: ', arguments);
        }
    }
});

And this is my update.php response :

<?php
echo '[ { "Id" : 1,'.
    '"Name" : "Planning Updated",'.
    '"expanded" : true,'.
    '"additionalData": ['.
    '    {'.
    '        "Name" : "T100",'.
    '        "parentId" : null'.
    '    }'.   
    ']'.
']';
?>
like image 842
mike_hornbeck Avatar asked Jan 17 '26 17:01

mike_hornbeck


1 Answers

The store's proxy always keeps the raw response from the most recent request. Try something like this and see if the information you need is there.

update : function(){
   console.log(this.proxy.reader.rawData);
}
like image 122
FoxMulder900 Avatar answered Jan 20 '26 05:01

FoxMulder900



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!