webanimals / dynatree

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

After expanding the lazy node without any children the triangle to expand/collapse does not disappear #454

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Steps to reproduce:
1. Define onLazyRead callback which doesn't add any child nodes
2. Expand any lazy node.
Expected behavior: the icon (triangle) to expand/collapse the node will 
disappear.
Current behavior: the icon is still in its place. 

jsFiddle: http://jsfiddle.net/Ld6aZ/1/

Dynatree version: 1.2.4

Original issue reported on code.google.com by alkol...@gmail.com on 6 Sep 2013 at 11:45

GoogleCodeExporter commented 9 years ago
By convention, if an JSON respionse contains [] (empty list), that means 'no 
child nodes', so the expander will be removed.
undefined or null means 'not tried to load'

Original comment by moo...@wwwendt.de on 6 Sep 2013 at 5:56

GoogleCodeExporter commented 9 years ago
In 'onLazyRead' I add child nodes programmatically, not using ajax. I get an 
array with  JSON data from some external source and then call 'addChild' method 
for each item. If the array is empty, 'addChild' will not be called and the 
icon will not disappear.
I updated jsFiddle to demonstrate the simplified version of my code: 
http://jsfiddle.net/Ld6aZ/4/
What JSON response do you mean?

Original comment by alkol...@gmail.com on 6 Sep 2013 at 9:45

GoogleCodeExporter commented 9 years ago
In that case you can do this for empty responses:

    node.childList = []; 
    node.render();

With JSON response I meant the Ajax response that is returned by the server, if 
you use node.appendAjax(). (This is the most common use case for Dynatree lazy 
loading I think)

N.b. 
From a usability perspective it might be nicer to avoid marking these nodes as 
lazy in the first place. Otherwise every user has to click to find out it's 
empty.

Original comment by moo...@wwwendt.de on 7 Sep 2013 at 8:48

GoogleCodeExporter commented 9 years ago
Thank you for the workaround, it works.

Original comment by alkol...@gmail.com on 25 Sep 2013 at 9:58

GoogleCodeExporter commented 9 years ago
Cleanup Scrumboard

Original comment by moo...@wwwendt.de on 2 May 2014 at 7:47