DEMO: Lazy Loading Datastore used by dijit.Tree


This simple demo shows how the dijit.Tree widget can work with a Datastore that does lazy-loading of values into the tree. In this demo, the Datastore is an extension of ItemFileReadStore that overrides the isItemLoaded() and loadItem() functions of with ones that can detect 'stub' items and use the data in the stub item to load the real data for that item when it is required. In this demo, the real data is required when one of the tree nodes is expanded.

The key thing to note is that all the lazy-loading logic (how to locate the data from the backend and so forth) is encapsulated into the store functions. The dijit.Tree widget only knows about and uses the API interfaces to call to the store to get items, test if child items are fully loaded or not, and to invoke the loadItem() function on items that are not yet fully loaded but have been requested to be expanded into view. It has no knowledge of how the store actually goes and gets the data.