简体   繁体   English

LightSwitch HTML客户端无需刷新整个页面即可自动运行查询

[英]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. 在Lightswitch HTML客户端中,我们创建了一个屏幕来显示特定业务流程的进行中的工作。

This is to be displayed on a big screen, much like when you go to Argos to collect your order. 这将在大屏幕上显示,就像您去Argos收集订单时一样。 Here's a screenshot... 这是截图...

在此处输入图片说明

We are using some java script to refresh the page every 30 seconds. 我们正在使用一些Java脚本每30秒刷新一次页面。

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) (数据由WCF RIA服务提供给LightSwitch)

In the JavaScript, use screen.MyList.load() . 在JavaScript中,使用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. 请注意,IntelliSense并不总是在screen对象上建议列表名称,但是如果您键入名称,它将识别它们。

Combined with the setTimeout() method and the created screen event, it should work. 结合setTimeout()方法和created屏幕事件,它应该可以工作。

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. setTimeout将仅触发一次,但setInterval将每1秒钟触发一次。

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. 我在LightSwitch VS2012 Update 3上遇到了同样的问题,因为我的情况就是无效就足够了,所以我总是可以使用一个新的实体。 This code runs once on entry screen and invalidates loaded entities every 30 seconds, and forces a refetch just when needed. 此代码在输入屏幕上运行一次,每30秒使加载的实体无效,并在需要时强制进行重新提取。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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