Synch on multiple elements

I have a tabbedView that has a tableView and a treeView as children. The requirement is to populate the treeView from a URL and then pick and display the highest two rows in the tableView. I do this by maintaining a TreeCollection.

  1. The treeCollection is which is copied to a DataCollection after completing loading.
  2. The DataCollection is then sorted descending and then truncated to keep the top two entries.
  3. Then I need to select the first row in the tableView.

Please see : https://snippet.webix.com/hs7jdx2b

This all works but is timing dependent. The snippet is simple but in my actual page if I keep refreshing the page, once in a while I get an error at line 25 which is

var firstId = tbl.getFirstId();

The error is getFirstId not found for undefined. It seems that data loading completed before the tableView was rendered. How do I assure that I can get rid of this sporadic issue ?

Hi,

data loading completed before the tableView was rendered

The issue sounds unclear, as rendering is a final step of initialization which has to work properly, especially when there is only one async operation which end is detected correctly with onAfterLoad event.
I would be glad if you can include the debug version of the library instead of the minified webix.js and provide the error stack.

However, if the datatable is undefined at this point, please try to init it prior to the collection.

As a side note, I would suggest simplifying the code as follows:

https://snippet.webix.com/ipaf534y

I think moving the load to after the webix.ui block is what solves the problem. Thanks for the simplified code.