1. #1
    Sencha User
    Join Date
    Sep 2007
    Posts
    35
    Vote Rating
    0
    DannyR is on a distinguished road

      0  

    Default How to delete a node off the tree?

    How to delete a node off the tree?


    This shouldn't be that hard, should it? I need to search through the store to find nodes that meet a certain criteria, and simply delete them (be they leaves or branches)?

    Here's what I've got:

    Code:
    var store = tree.getStore();store.doOnLoad(function(store) {
        var root = Ext.valueFrom(null, tree.getRootNode());
        root.cascadeBy(function(node) { 
            if (node.get("archived") == true) {
                store.getById(node.internalId).remove();
            }
        });
    });
    It's throwing a "childNodes[i] is undefined" error: childNodes[i].cascadeBy(fn, scope, args); [ext-all-dev.js (line 56625)]

    Since it's throwing that inside a recursion loop, it would seem to indicate that it doesn't know to not follow that branch when its ancestor has been deleted. But that's only a guess at this point.

    Been beating my head against the wall for far too long on this one. Any help would be greatly appreciated.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,582
    Vote Rating
    433
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    You need to use the removeChild method on the parent node
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.