简体   繁体   中英

LightSwitch HTML Client to automatically run queries without refreshing entire page

In Lightswitch HTML client we have created a screen to display the work in progress for a particular business processes.

This is to be displayed on a big screen, much like when you go to Argos to collect your order. Here's a screenshot...

在此处输入图片说明

We are using some java script to refresh the page every 30 seconds.

setTimeout(function () {
    window.location.reload(1);
}, 30000);

However, there are two issues with this.

  1. The 'maximum number of results' text input by the user is lost on refresh.
  2. It doesnt look nice to refresh the whole page.

Is it therefore possible to just trigger each query to reload instead of the entire page?

(The data is provided to LightSwitch by a WCF RIA Service)

In the JavaScript, use screen.MyList.load() . It will reload the list asynchronously.

Note that IntelliSense does not always suggest list names on the screen object but will recognize them if you type the name.

Combined with the setTimeout() method and the created screen event, it should work.

I had the same issue and finally found the solution. I added this in my created event:

myapp.BrowseMembers.created = function (screen) {
    setInterval(function () {screen.Members.load(true);}, 1000);
};

Ii works, just the screen get flickering when reloading the data. setTimeout will only trigger once but setInterval will trigger every 1 second.

I had the same problem with LightSwitch VS2012 Update 3, for my case just invalidation is enough, so i can always work with a fresh entity. This code runs once on entry screen and invalidates loaded entities every 30 seconds, and forces a refetch just when needed.

myapp.aaHome.created = function (screen) {
    setInterval(function () { 
        screen.details.dataWorkspace.ApplicationData.Currencies._loadedEntities = {};
    }, 30000);
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM