on 12-29-2014 5:49 AM
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
HI Koti
You can use SAPUI5 model binding to bind the headerText to the array in the model like this.
-D
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
Hello Koti and Dennis,
Here is a version of your discussion and code using an XML View,
Hope this helps,
Scott
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.