Question

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;
    });
};
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top