Threaded View

  1. #1
    Sencha User
    Join Date
    Jul 2010
    Posts
    33
    Answers
    1
    Vote Rating
    0
    charles.bourasseau is on a distinguished road

      0  

    Default Answered: extjs 4.1 tree add new node with server changes

    Answered: extjs 4.1 tree add new node with server changes


    In my application, the user can add some nodes to a tree node. The tree is connected to a store which has autoload and autosync true.The code to add a new node is this one:
    Code:
    var window = button.up('window');
    var form = window.getComponent('NodeForm').getForm();
    var store = Ext.getStore('NodeStore');
    var parentDir = window.parentDir;
    record = window.record ? window.record : NuageApp.model.Node.create();
    
    
    if (form.isValid()) {
        form.updateRecord(record);
        if (window.record) {
            store.sync();
        } else {
            parentDir.appendChild(record);
        }
        window.destroy();
    }
    Then the server will be notified and returns this json:
    Code:
    {
       "id": "4faccf93f597090d14000010/home/user/file",
       "text": "test file",
       "type": "file",
       "icon": "/images/icons/page.png",
       "expanded": true,
       "children": []
    }
    The property text and icon changed server side but the store does not update the record.


    Code:
    Here is the configuration of the store:
    Ext.define('MyApp.store.NodeStore', {
        extend: 'Ext.data.TreeStore',
        requires: [
            'MyApp.model.Node'
        ],
    
    
        constructor: function(cfg) {
            var me = this;
            cfg = cfg || {};
            me.callParent([Ext.apply({
                autoLoad: true,
                autoSync: true,
                storeId: 'MyJsonTreeStore1',
                model: 'MyApp.model.Node',
                proxy: {
                    type: 'rest',
                    reader: {
                        type: 'json',
                        idProperty: 'id'
                    },
                    writer: {
                        type: 'json',
                        nameProperty: 'text'
                    }
                },
                sorters: {
                    property: 'text'
                },
    
    
            }, cfg)]);
        },
    
    
    });



  2. Try to return json data as an array:
    Code:
    [{
       "id": "4faccf93f597090d14000010/home/user/file",
       "text": "test file",
       "type": "file",
       "icon": "/images/icons/page.png",
       "expanded": true,
       "children": []
    }]
    Or
    Code:
    { 
        "success": true,
        "children": [{
           "id": "4faccf93f597090d14000010/home/user/file",
           "text": "test file",
           "type": "file",
           "icon": "/images/icons/page.png",
           "expanded": true,
           "children": []
       }]
    }

Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi