cancel
Showing results for 
Search instead for 
Did you mean: 

Panel header text should display total number of rows in sap.m.table

Former Member
0 Kudos

Hi,

I was able to read number of rows in a table for which data is coming from Odata entityset.If I try to set panel header text , initially it is not displaying count.

If I try to display from on init () method , it is displaying as 0 count as odata might not be generated by the time table loads. I tried the same code in different hook methods but no luck.

Is there any different method which I can use to display total number of rows count on table header during first time loading.

If there is anymethod to calculate the count from entityset , please share the sample code as well.

I used below code to set Panel headertext from onSelectionChange method.

    var mytab=this.getView().byId("testTable");

    var count = mytab.getItems().length;

   

    this.getView().byId("pn1").setHeaderText("Products"+"("+count+")");

Regards,

Koti Reddy

Accepted Solutions (1)

Accepted Solutions (1)

former_member182862
Active Contributor
0 Kudos

HI Koti

You can use SAPUI5 model binding to bind the headerText to the array in the model like this.

-D

Former Member
0 Kudos

Hi Dennis,

Please help me to write the JS into XML View code related to your code.

var oPanel = new sap.m.Panel({

    headerText: {

      path: '/result',

      formatter: function(arr) {

        return 'Number of Row(s): ' + (arr ? arr.length : 0);

      }

    },

I like this way of reading model data to get total number of items even though I achieved it from updateFinished method.

Regards,

Koti Reddy

former_member182862
Active Contributor
0 Kudos

Can someone in this space help?

I do not use XML in SAPUI5.

Thanks

-d

scott_stefanich
Active Participant
0 Kudos

Hello Koti and Dennis,

Here is a version of your discussion and code using an XML View,

Panel Header Text Row Count

Hope this helps,

Scott

Answers (2)

Answers (2)

0 Kudos

Hi Koti

If you are using the mobile library (which i assume, considering panel control),

Please make use of the event updateFinished of the sap.m.Table control like this:

updateFinished: function(evt) {

     if(evt.mParameters.reason == "Change") {

          oPanel.setHeaderText(evt.mParameters.total);

     }

}

Parameter total holds the total number of bound items.

You may use  parameter "actual" for total number of items fetched by oData.

Hope this was helpful.

Thanks and Regards

Shubhang

Former Member
0 Kudos

Hi Shubhang,

You gave me correct method which I was looking from long time. It worked with below code as per my snippet.

onUpdateFinished: function(oEvent){

   

 

    var actual =   oEvent.getParameters().actual;

    this.getView().byId("pn1").setHeaderText("uploads" + "("+actual+")");

  

    }

Regards,

Koti Reddy

nabheetscn
Active Contributor
0 Kudos

Hello Koti

Did you try checking in debugging mode whether your assignment was returning any value?

You can try using

oPanel.addContent(new sap.ui.commons.TextView({text: "Here pass your value));

Thanks

Nabheet