1

在 Lightswitch 2013 中,我想在屏幕上显示给定查询 (FilteredIncidents) 中的项目总数 (Incidents) - 例如:

“显示 5000 个事件中的 200 个”。

但是,我只能获取屏幕上加载的项目数。如何显示总数?

这就是我正在做的获取已加载到屏幕上的项目的数量:

myapp.BrowseIncidents.TotalIncidents_postRender = function (element, contentItem) {
    contentItem.dataBind('screen.FilteredIncidents.count', function (value) {
        contentItem.screen.TotalIncidents = value;
    });
};
4

1 回答 1

4

我使用这样的功能。您可以调整参数以适应,例如传入一个元素而不是和 id:

    function getTotalCount(entitySet, elemId) {
    entitySet
       .top(1)
       .includeTotalCount()
       .execute()
       .then(function (result1) {
           // update the total count
           document.getElementById(elemId).innerText = result1.totalCount.toString() + " rows";
       }, function (error) {
           // do whatever you want to
           totalProperty = "error";
       });
}

戴夫

于 2014-03-20T13:11:50.487 回答