Announcement

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

    Hook to detect changes to datasource for a ListGrid

    I have the case where I show the row count with the displayed ListGrid. The row count gets updated via a DataArrivedHandler that is added to the ListGrid and in that handler I call "getTotalRows()" to populate the count label displayed on the UI.

    That all works very nicely except for the case where a DS operation results in related updates via "addRelatedUpdate" where in some cases will cause new rows to show up in the ListGrid and/or some rows being removed from the ListGrid. When this happens our ListGrid is updated automatically (new rows appear, deleted rows are removed) but my count label does not get updated since I take it that the related updates does not cause data arrived handler to fire?

    What would you recommend as the best way to accomplish this (updating the count when the ListGrid rows are changed)?

    Is using the DataArrivedHandler OK to use for this in the general case? If so, any suggestions for the related update changes?

    Thanks.

    SmartClient Version: v9.1p_2014-08-11/Pro Deployment (built 2014-08-11)

    #2
    The DataChanged event allows you to respond to these kinds of changes.

    Comment


      #3
      Thanks for the response.

      Comment


        #4
        I have this working nicely with the exception of the 1000 value "flashing" when a new fetch is performed (say clicking a column to cause a new sort which then results in a new fetch to the server).

        I have seen in another post you mention that the total rows gets set to 1000 under certain conditions. Any suggestions on how I should handle this (other than checking for the value of 1000 explicitly)?

        The handler below is what I am using and the data arrived handler also calls the same updateCount() method which just updates a label with the total count of the ListGrid via getTotalRows().

        One of the scenarios is this:
        - count label shows 367 (100 rows actually fetched)
        - click a column to change the sort
        - count label shows 1000
        - fetch returns
        - count label gets set back to 367

        Code:
               ResultSet rs = new ResultSet();
                rs.addDataChangedHandler(new DataChangedHandler() {
                    @Override
                    public void onDataChanged(DataChangedEvent event) {
                       updateCount();
                    }
                });
        
                setDataProperties(rs);
        Thanks.

        Using: SmartClient Version: v9.1p_2014-08-31/Pro Deployment (built 2014-08-31)

        Comment


          #5
          See ResultSet.lengthIsKnown().

          Comment


            #6
            Exactly what I was looking for. Thank You Kindly!

            Comment

            Working...
            X