Results 1 to 2 of 2

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

  1. #1
    Sencha User
    Join Date
    Sep 2009
    Posts
    6
    Vote Rating
    0
      0  

    Default 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 User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347
    Vote Rating
    114
      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'
        }]
    });

Tags for this Thread

Posting Permissions

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