In Lightswitch 2013 I want to show the total number of items (Incidents) in a given query (FilteredIncidents) on the screen - something like:
"Showing 200 of 5000 Incidents".
However, I'm only able to get the number of items that are loaded on the screen. How can I show the total?
This is what I'm doing to get the count of the items that have been loaded on the screen:
myapp.BrowseIncidents.TotalIncidents_postRender = function (element, contentItem) {
contentItem.dataBind('screen.FilteredIncidents.count', function (value) {
contentItem.screen.TotalIncidents = value;
});
};
I use a function like this. You can adjust the parameters to suit, like pass in an element rather than and 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";
});
}
Dave