gpt4 book ai didi

javascript - 显示一个集合的总数

转载 作者:行者123 更新时间:2023-11-30 10:18:47 25 4
gpt4 key购买 nike

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

"Showing 200 of 5000 Incidents".

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

这就是我正在做的事情,以获取屏幕上已加载的项目数:

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

最佳答案

我使用这样的函数。您可以调整参数以适应,例如传入一个元素而不是 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";
});
}

戴夫

关于javascript - 显示一个集合的总数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22417351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com