-1

I need table bound data total rows number for further loop. How can we get table rows count?

I'm getting undefined on button press:

var tab= this.getView().byId("idOrderDetailTable");
var obj = tab.getBindingContext("ProductCollection");
console.log(" >> ",obj );
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Kitty
  • 179
  • 6
  • 13
  • 29
  • Does this answer your question? [Live Update the Number of Items](https://stackoverflow.com/questions/48308896/live-update-the-number-of-items) – Boghyon Hoffmann Jun 01 '22 at 12:15

3 Answers3

0
var tab= this.getView().byId("idOrderDetailTable");
//get binding path of table items 
var bindingPath = tab.getBinding("items").sPath;
//get data model of table
var model = tab.getModel();
//get bind data
var data = model.getProperty(bindingPath);
//get total rows number
var rowCount = data.length;
console.log(" >> ",rowCount );
Haojie
  • 5,665
  • 1
  • 15
  • 14
0
var tab= this.getView().byId("idOrderDetailTable");
var length = tab.getItems().length

This should be a simpler way.

sakthi
  • 929
  • 6
  • 18
-1

If you use sap.ui.table.Table and didn't bind Model:

var length = oTable._iBindingLength;
sam750
  • 1
  • 1
  • 1
    Please avoid relying on private members (`._`) from the framework code. This **will** break the application in newer framework releases. Use only what is visible in the public API reference. – Boghyon Hoffmann Jun 01 '22 at 12:07