mar10 / dynatree

Automatically exported from code.google.com/p/dynatree
92 stars 37 forks source link

[patch] Recursive load path based on any attribute #416

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Dynatree is very impressive. It's simple to use yet very powerful. Though there 
was one thing I couldn’t do with Dynatree: lazy load and select a node based 
on an attribute other than ‘key’. There’s a method loadKeyPath that does 
the trick for the attribute ‘key’. I’ve added a method that provides the 
same functionality but for any other attribute available.

I noticed that it’s also only possible to get the key-based path for a node. 
So I added an additional method to get the path based on a custom attribute.

New methods:
 * loadPath(attr, path, callback, pathSeparator)
 * getPath(attribute, excludeSelf, pathSeparator)

The ‘old’ method loadKeyPath and getKeyPath are replaced with an 
implementation of the new methods:

loadKeyPath: function(keyPath, callback) {
    return this.loadPath("key", keyPath, callback);
}

getKeyPath: function(excludeSelf) {
    return this.getPath("key", excludeSelf, this.tree.options.pathSeparator);
}

I’ve added an extra ‘pathSeparator’ argument to provide extra 
flexibility. I renamed options.keyPathSeparator to options.pathSeparator to 
give it a more meaningful name as it is now used as the fall-back separator if 
none is given as argument.

Note that if an attribute is not unique for a child, the first child with that 
attribute is loaded.

Please refer to the attached patch for details on the modifications. I hope 
that this patch can be of use for other developers and maybe can be a good 
attributions for a next release.

Original issue reported on code.google.com by prie...@gmail.com on 2 Apr 2013 at 7:21

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks!

Original comment by moo...@wwwendt.de on 9 Apr 2013 at 11:15

GoogleCodeExporter commented 9 years ago

Original comment by moo...@wwwendt.de on 6 Oct 2013 at 4:35

GoogleCodeExporter commented 9 years ago
As of 2014 Dynatree is feature frozen.
Please have a look at Fancytree (sequel of DynaTree 1.x): chances are good that 
the problem was resolved / the requested featuer is already implemented.
Please open a new issue there otherwise:

https://github.com/mar10/fancytree

Original comment by moo...@wwwendt.de on 1 May 2014 at 4:38