1. #1
    Sencha User
    Join Date
    Sep 2009
    Posts
    6
    Vote Rating
    0
    Frederes is on a distinguished road

      0  

    Default Unanswered: Tree reordering : update event (server call) not fired when insert after/before node

    Unanswered: Tree reordering : update event (server call) not fired when insert after/before node


    Hello,

    I want to reorder a Tree using the 'treeviewdragdrop' plugin.
    When i move the node into another (changing the parent), the update event (autoSync = true) is fired ans server URL is called.
    But when i just move the node inside its parent, after or before its siblings, the server URL is not called and so i can't save the new order/index for this node.

    Here my code :

    Code:
    var store = Ext.create('Ext.data.TreeStore', {
                    proxy: {
                        type: 'ajax',
                        actionMethods: 'post',
                        url: 'get_or_update_nodes.php'
                    },
                    autoSync: true,
                    root: {
                        text: 'Prixorama',
                        id: 'root',
                        expanded: true
                    },
                    folderSort: true,
                    sorters: [{
                        property: 'left', // i use nested categories, this comes from server database
                        direction: 'ASC'
                    }]
                });
    
    var tree = Ext.create('Ext.tree.Panel', {
                    store: store,
                    rootVisible: true,
                    collapsible: true,
                    multiSelect: true,
                    viewConfig: {
                        plugins: {
                            ptype: 'treeviewdragdrop',
                            allowParentInserts: true,
                            appendOnly: false
                        },
                    },
                    renderTo: 'tree-div',
                    height: 500,
                    width: 500,
                    title: 'Categories',
                    useArrows: true,
                });
    How to solve this ..? Is it a bug ?

    Thank you for any help !

    Fred

  2. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    It's not a bug. When you reorder nodes within the same parent, only their index property is changed. Because index is not a persist property of a node so changing this property does not generate updating request. If you want to do the updating when changing the order of nodes in the same parent, you should define index as a persist property of node.
    Code:
    var store = Ext.create('Ext.data.TreeStore', {
        fields: ['text', 'index', ...],
        proxy: {
            type: 'ajax',
            actionMethods: 'post',
            url: 'get_or_update_nodes.php'
        },
        autoSync: true,
        root: {
            text: 'Prixorama',
            id: 'root',
            expanded: true
        },
        folderSort: true,
        sorters: [{
            property: 'left', // i use nested categories, this comes from server database
            direction: 'ASC'
        }]
    });

Thread Participants: 1

Tags for this Thread