cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Record Count in Multiple Views of Smart-tables

RaminS
Active Participant
1,636

I have a Smart-table tied to a smart-filterbar, and I am displaying multiple-views in the table, (implemented by icon filters).

I want to show a count for each tab. But the smart table only retrieves the count of the current tab. I tried a trick to submit a manual odata $count with the other filters in onBeforeRebindTable method. But I don't want it to perform counts if the criteria has not changed. I only want to re-count when user clicks Go in the smart filterbar.

I see screenshots in SAP documentation of List Reports with multiple-views that automatically display counts of all tabs. How do they do that? and why can't we do the same thing for Smart tables? List reports are based on smart-filter and smart-tables afterall.

Any help would be appreciated.

SAP Docs

Accepted Solutions (0)

Answers (3)

Answers (3)

Joseph_BERTHE1
Active Contributor

Hello,

The List Report is a template with lot of build-in logic. Just because you use Smart Controls does not mean that all the logic of a Fiori Element will be implemented.

For your point, you can use the event updateFinished in your binding and then find the different count. But you can also send 3 request $count with different filters.

For exemple :

<mvc:View 
  controllerName="view.Root"
  xmlns:mvc="sap.ui.core.mvc"
  xmlns="sap.m"
>
  <List id="list"
    headerText="Categories"
    items="{/Categories}"
    growing="true"
    growingThreshold="4"
    growingScrollToLoad="true"
    updateFinished=".countProducts"
  >
    <ObjectListItem
      title="{description}"
      numberUnit="Products"
    />
  </List>
</mvc:View>

Controller.js

countProducts: function(e){
  var m = sap.ui.getCore().getModel();
  var items = this.byId("list").getItems();    
  for (var item_index = 0; item_index < items.length; item_index++) {
    var item = items[item_index];
    (function(_item) {
      $.get(
        m.sServiceUrl + _item.getBindingContextPath() + "/Categorias/$count",
        function(count) {
          _item.setNumber(count);
        }
      );
    })(item);
  }
}

source: https://stackoverflow.com/a/30244325

Regards,

Joseph

RaminS
Active Participant
0 Kudos

Thanks Joseph. Smarttable doesn't seem to have the event updateFinished. And dataReceived is deprecated. And as I mentioned, beforeRebindTable triggers everytime the table is rendered (not when new data is received) so I can't use it.

What event can we use instead of updateFinished?

Thanks.

Joel_John
Participant
0 Kudos

Multiple views for a List Report table in Fiori Elements | SAP Blogs

This blog might help anyone else facing the same question.

Joel_John
Participant
0 Kudos

Use showCounts : true in the variant settings.

This is found in the sap.ui.generic.app section in the manifest.json.

"quickVariantSelectionX": {
"enableAutoBinding": true,
"showCounts": true,
"variants": {
"Header": {
"key": "Header"
}
}
}
RaminS
Active Participant
0 Kudos
This is not a Fiori Element app. The question is about SmartTables. I already know how to do it in a Fiori Element list-report.