Search code examples
oracle-jet

Lazy loading in oj-tree-view in 4.x


I was using Oracle Jet 3.2 and the oj-tree supported lazy rendering of child elements. I am upgrading to OJet 4.1 and I am not able to figure out how to support this(lazy rendering) in the new implementation of tree, i.e. oj-tree-view. There aren't any relevant examples in the cookbook too. The oj-tree-view code too doesn't help much

I guess the old oj-tree(from 3.2) would still work as they claim to be backward compatible but I would like to upgrade the code to 4.1 level.


Solution

  • So the way 4.x ojTree works is you'll need to attach a datasource while defining the tree. Something like <oj-tree-view id="treeview" data ="treeDataSource".... . treeDataSource here can be an instance of oj.CollectionTreeDataSource which provides a callback param, childCollectionCallback. This callback is always invoked when you try to expand a tree node. We can have our logic to fetch the data from server here.