Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Filter/Fetch data and getting total count for client-side responses

    Hello Isomorphic,

    I am sure this is a simple question. I am using Smart Client 8.3 and calling filterData() on my ListGrid and want to display the total number of filtered results for adaptive filtering. I can get the total result count from server-side responses by passing a callback function as the second argument in filterData() but when filtering is done client-side instead of going to the server, how do I get the total count? Is there one single recommended way to get the total number of results to populate the list grid irrespective of whether it goes to the server to fetch or it is done on the client-side?

    Thanks.

    #2
    The simplest approach is to add a dataChanged() override and call getTotalRows().

    Comment


      #3
      Thanks for your response. I tried using dataChanged and calling my Javascript function which gets the total count and displays it. However, my filtering in the list grid doesn't work anymore even though the count displayed is correct. The ListGrid still shows all unfiltered records. Am I supposed to do something else like return true in updateRowCountLabel() for the ListGrid to be filtered? I can't find any documentation in the Reference docs on ListGrid.dataChanged. I just see documentation for List.dataChanged.

      Code:
      isc.ListGrid.create({
      		ID: "myGrid",
      		width: "*",
      		dataSource: MyDS,
      		dataChanged: updateRowCountLabel
      });
      
      updateRowCountLabel = function () {
      	var totalRows = myGrid.getTotalRows();
      	filterLabel.updateTotalCount(totalRows);
      }
      
      ....
      commentsGrid.filterData(criteria);
      If I remove dataChanged and just add a callback in filterData, the ListGrid is populated fine with the filtered records.

      Code:
      commentsGrid.filterData(criteria, updateRowCountLabel);

      Comment


        #4
        You are overriding dataChanged, so you need to call Super.

        See Class.Super if you have not done this before.

        Comment


          #5
          Thanks. I missed calling Super.dataChanged...that fixed the issue. I knew I was missing something simple.
          I also had to call setTimeout on filterLabel.updateTotalCount(totalRows); because otherwise, the filterLabel flashed 1000 as the total count when it fetched from the server, before updating with the correct total count. Is there a way to prevent this flashing?
          Last edited by mgreenberg; 13 Aug 2013, 15:04.

          Comment


            #6
            You can call the lengthIsKnown API on the ResultSet (data object) to determine whether the length is known

            Comment


              #7
              Sweet! Thanks!

              Comment

              Working...
              X