Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Ext User
    Join Date
    Apr 2008
    Posts
    80
    Vote Rating
    0
    varsha.kothari is on a distinguished road

      0  

    Question Problem in removing a node from tree:deletin alternate node

    Problem in removing a node from tree:deletin alternate node


    Hi,
    I am facing a problem while deleting node from a tree.
    I have a tree which has suppose 5 childs:
    -Root
    +C1
    +C2
    -C3
    +CC1
    +C4

    Now my requirement is that when I click on CC1 then C1, C2, C4 should be remomved from "Root".
    I tried using this code in tree.onClick :

    Ext.each(delnode.childNodes, function(item)
    {
    alert("item:"+item.text+"id"+item.id);
    if(item != my.id){
    delnode.removeChild(item);
    }

    });

    Now the problem is : Its deleting alternate nodes i.e. it will delete C1 then leave C2, then delete C4. I tried it several times but its not picking every node.

    Please suggest something quickly...........
    Thanks in advance

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,608
    Vote Rating
    580
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Your code looks a little strange, I would think something like this:

    Code:
    myTree.on('click', function(node)
    {
       var parent = node.parentNode;
       if (parent) //make sure we didn't click the root
       {
          Ext.each(parent.childNodes, function(child)
          {
             if (node !== child)
                parent.removeChild(child);
          }
          );
       }
    }
    );
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Ext User
    Join Date
    Apr 2008
    Posts
    80
    Vote Rating
    0
    varsha.kothari is on a distinguished road

      0  

    Arrow My code is similar to yours but its deleting only alternate nodes

    My code is similar to yours but its deleting only alternate nodes


    Hi, My code is similar to what you posted, delnode is "parent" for my code. I have got delnode by some calculations because there are multiple levels of tree.

    But the main problem is that it deletes only alternate nodes. i.e. it skips the node that is just next in tree to that deleted node. Eg.

    +A
    +B
    +C

    Here A will be deleted and C will be deleted but B is skipped and is still there.
    Is this the behaviour of removeChild method().
    I tried using remove() in same fashion but its also deleting alternate nodes in tree.

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,608
    Vote Rating
    580
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Oh, duh. By removing nodes you're invalidating the iterator.

    Code:
    var toRemove = [];
    Ext.each(parent.childNodes, function(child)
    {
       if (node !== child)
          toRemove.push(child);
    }
    );
    
    Ext.each(toRemove, function(item)
    {
       parent.removeChild(item);
    }
    );
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Ext User
    Join Date
    Apr 2008
    Posts
    80
    Vote Rating
    0
    varsha.kothari is on a distinguished road

      0  

    Arrow its deleting alternate nodes in tree.

    its deleting alternate nodes in tree.


    Hi, My code is similar to what you posted, delnode is "parent" for my code. I have got delnode by some calculations because there are multiple levels in tree.

    But the main problem is that it deletes only alternate nodes. i.e. it skips the node that is just next in tree to that deleted node. Eg.

    +A
    +B
    +C

    Here A will be deleted and C will be deleted but B is skipped and is still there.
    Is this the behaviour of removeChild method().
    I tried using remove() in same fashion but its also deleting alternate nodes in tree.
    Can you tell me the exact behaviour, what is happening?
    Thanks....
    Last edited by varsha.kothari; 14 Jul 2008 at 12:55 AM. Reason: Sorry for this reply, I thought its not posted so reposted.

  6. #6
    Ext User
    Join Date
    Aug 2008
    Posts
    48
    Vote Rating
    0
    ndtreviv is on a distinguished road

      0  

    Default Node removal error

    Node removal error


    Here is the error:
    Code:
    nodes[i] has no properties
    (no name)(Object tId=4 status=200 statusText=OK)ext-all-debug.js (line 3570)
    apply(function(), undefined, [Object tId=4 status=200 statusText=OK, Object url=./path/to/updater.jsp method=post], undefined)ext-base.js (line 9)
    handleResponse(Object tId=4 status=200 statusText=OK)ext-all-debug.js (line 5317)
    getViewWidth(Object conn=XMLHttpRequest tId=4, Object scope=Object argument=Object timeout=30000, undefined)ext-base.js (line 10)
    getViewWidth()ext-base.js (line 10)
    [Break on this error] v = this.getStyle(styles[sides.charAt(i)]);
    In this case, nodes was an array of TreeNode objects. I was iterating through them using a standard for loop, rather than the each() iterator, and attempting either nodes[i].remove() or nodes[i].parentNode.removeChild(nodes[i]).

    I believe the problem has something to do with the re-draw triggered by the "unselect" event fired by the MultiSelectionModel when the removeChild function is called on the TreeNode object. I don't have much evidence to back this up - it's just a hunch at the moment.

    It might be worth mentioning that instead of a pure TreePanel, I'm using the ColumnTree extended from TreePanel, and used in Ext-js examples.

    If I can submit anything further that may help, please let me know!

  7. #7
    Ext JS Premium Member
    Join Date
    Feb 2008
    Posts
    40
    Vote Rating
    0
    oburlaca is on a distinguished road

      0  

    Default


    I've just encountered the same problem.
    I was trying to do one of the following:
    Code:
    nodes = treePanel.getSelectionModel().getSelectedNodes();
    Ext.each(nodes, function(n) {n.remove()}, this);
    As evant mentioned earlier, "By removing nodes you're invalidating the iterator."

    second try:
    Code:
    nodes = treePanel.getSelectionModel().getSelectedNodes();
    for (var i=0; i<nodes.length; i++) { 
    var n = nodes[i];
    n.remove();
    }
    this also doesn't work because nodes.length is evaluated each time, and is decreasing with each iteration.

    So I've jus tried to go from the end to the beggining of the array.
    This code works for me:
    Code:
    for (var i=nodes.length-1; i>=0; i--) {
    var n = nodes[i];
    n.remove();
    }
    AeroSQL - Web based MySql manager (PHP+ExtJS)
    www.burlaca.com - My blog