Domanda

How to append a child on a specific position (as default the new child will appear after the last node)


My solution is to use a variable of order

function treeGridReorder(){
        var i=0 ,j = 0;
        treeGrid.getView().getStore().each(function(node){
            node.data.ordre=i;
            j=0;
            node.eachChild(function(cnode){
                cnode.data.ordre=j;
                j++;
            });
            i++;
        })
    }

function add_reponse(quest, qIndex){
        questStr.sort('ordre', 'ASC');
        var now=new Date().getTime();
        questStr.getNodeById(quest).appendChild({id:now, libelle:'Nouvelle réponse',parentq:quest,  saved:false, leaf: true});
        treeGridReorder()
    }
È stato utile?

Soluzione

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top