Skip to Content
avatar image
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Dec 29, 2014 at 08:08 AM

    HI Koti

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

    -D

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 29, 2014 at 07:08 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • Dec 29, 2014 at 06:34 AM

    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

    Add comment
    10|10000 characters needed characters exceeded