Privacy Policy and Cookies

By continuing to use our site, you agree to our Privacy Policy and our use of cookies to understand how you use our site, and to improve your experience. Learn More.
I Agree.

Best practices: loading DataSources dynamically

Last modified date

Just came across this great blog post from SmartClient user David Johnson about a technique for loading required DataSources dynamically as part of a view.

“So how do we provide DataSources customized for the user? Well, we could easily pull the metadata from the database, merge in the user’s security and then write the DataSources into the web page (we are using ASP.Net).

As there will ultimately be around 200 DataSources in the application the time to build every one of them at login time was considered too long.”

The post goes on to describe a custom class, similar to ViewLoader, that handles automatic DataSource loading as part of a transition to a new set of application views. Usage ultimately look like this, where the viewClass provides a list of DataSources that it requires in order to function:

_rightPane.addTab({
     ID: tabId,
     title: name,
     canClose: true,
     pane: ViewDependencyLoader.create({
         autoDraw: false,
         viewClass: className
     })
});

Great stuff, and David shares the complete source to his solution.

This is also an area where SmartClient will be expanding in the future, with APIs designed to help you more easily load a view along with the data it will need to initially operate, as well as manage a pool of views, for very large applications where LRU (least recently used) or similar view management approaches become important.

ckendrick