[ 4 posts ]

Kunal Kishore

  • Username: kunal.kishore123
  • Joined: Tue Jun 01, 2010 2:49 am
  • Posts: 10
  • IRC: Kunal
  • Offline
  • Profile

renderloopsize for yui tree ??

Post Posted: Fri Mar 30, 2012 12:12 am
+0-
Do we have something like renderLoopSize of datatable in yui tree 2 ?? I couldn't find anything like that in API.

If not, any sample code to achieve so?

Thanks,
Kunal


Last edited by kunal.kishore123 on Fri Mar 30, 2012 3:25 am, edited 1 time in total.

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: renderloopsize for yui tree ??

Post Posted: Fri Mar 30, 2012 12:38 am
+0-
For large amounts of data, you would use dynamic loading. Trees, unlike datatables, don't need all the tree expanded at once so instead of rendering all of it in batches, like DataTables do, you render it on demand, only when a branch gets expanded, if it does.

See:

http://developer.yahoo.com/yui/treeview/#dynamicloading

Kunal Kishore

  • Username: kunal.kishore123
  • Joined: Tue Jun 01, 2010 2:49 am
  • Posts: 10
  • IRC: Kunal
  • Offline
  • Profile

Re: renderloopsize for yui tree ??

Post Posted: Fri Mar 30, 2012 12:44 am
+0-
Thanks Satyam, for the quick reply.

I am already using dynamic loading. But in my case there are 1000s of child nodes at the same level under a parent node.

May be i can use setTimeout() to add child nodes in batches in my code. Any better solution is welcome.

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: renderloopsize for yui tree ??

Post Posted: Fri Mar 30, 2012 2:50 am
+0-
Basically, that is what renderLoopSize does, it uses setTimeout to release the UI to the user every once in a while. It actually takes longer to draw the whole thing but the user feels the interface more responsive than otherwise so it feels faster, though it isn't really so.

You would need to call the callback to tell the TreeView your dynamically loaded branch has been loaded the first time. This does not prevent you from further adding nodes on subsequent batches, but it will make sure the parent node displays properly. In other words, you don't need to wait for the whole branch to be added to call the callback, do it on the first batch and then keep adding nodes.

You will have to fine tune how many you add in each batch. Releasing control of the UI and take it back takes some time so you don't want to add a single node in each batch. renderLoopSize had to be at least 50, preferably more, to make any difference in DataTable, less than that it was slower.

If those child nodes are terminal nodes and they are all at the same depth, you might want to rethink it and display them like a file explorer, where the directory structure is on the left panel and the files are on the right panel displayed as a simple list, or even as a DataTable.
  [ 4 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum