Table loaded listener?

Hello,

I am trying display a message with the number of items returned when the table is loaded (as a property of the table).

How do I determine when a table has completed loading, is there a particular listener that fires?

Or is there a better way of going about this?

Thank you.

Short answer: There’s no such listener available.

Long answer: You could probably use some other listener to use this, depending on your specific situation and need (which was a bit unclear for me). First of all, a Table contains a Container (and actually
is
a Container, but let’s not go there now). That Table or its Container gets populated at some point, before it being rendered to the browser. So, one apparent place to display the size of the Table is at the place where you finish populating that.

So, you can’t get a message from Table when it’s populated (since, honestly, Table can never know when it’s completely populated, so that nothing else is ever added there). You know that yourself, once your code stops populating the container. Or, if you want it semantically closer to the Table, you could implement your own Container (by, e.g. extending IndexedContainer), and add your own event for that, possibly triggered by some isNowPopulated()-kind-of-method.

…or did I just completely misunderstand you?

Hi Paul,

yes you understood what I am trying to do correctly.

Its a nice to have. I will give your suggestion some more thought when I have got some of the more pressing stuff out of the way.

Thank you.

I want to do something simiilar. If the table (really container) is empty I would like to add a label when the table is empty. I created a new “DecoratedTable” component that adds this feature but would like to avoid having the client manaully calling something like “setNoDataLabelVisible()”.

I was thinking maybe the RequestRepaintListener might be feasible as a hook? Then I could check if the table’s container was empty or not and display the “no data” text.

Is this possible to do?

Thanks

In our application, we have our own Table component (extending the core component). Hopelly the following will point you in the right to detect the change in the number of rows : it works for us. Displaying the number of rows (or the noItemsPopup as we call it) is left as an exercise for the reader (we use a a special PopupView; you could use the PopupExtension add on)

HTH Cheers,

Charles.

 

public class SuperSpecialTable extends Table 
 private int rowCount = -1;
 [...]


@Override
  public void setContainerDataSource(Container newDataSource) {
    super.setContainerDataSource(newDataSource);
    updateRowCount();
  }


  @Override
  public void containerItemSetChange(Container.ItemSetChangeEvent event) {
    super.containerItemSetChange(event);
    updateRowCount();  
  }

  protected void updateRowCount() {
    int oldCount = rowCount;
    rowCount = getContainerDataSource().size();

    PropertyChangeEvent evt = new PropertyChangeEvent(this, "rowCount", oldCount, rowCount);
    if (pcs != null) {
      pcs.firePropertyChange(evt);
    }

    /* The number of rows has changed : show or hide the no items found message, if appropriate */
    if (isVisible()) {
      AuraWindow window = getAuraWindow();
      if (window != null) {
        if (rowCount == 0 && noResultsMessageEnabled) {
          showNoItemsPopup(window);
        } else if (window != null && noItemsFoundPopup != null) {
          hideNoItemsPopup();
        }
      }

    }
  }

Perfect. Thanks Charles! Love the class name :slight_smile: