cancel
Showing results for 
Search instead for 
Did you mean: 

Get Table Rows Count - Bind Aggregation

0 Kudos

Hi,

I want to get table row count, there is no issue in binding the data to table. But I couldn't able to get the row count.

                                oTable.bindAggregation("items", {

                                                                path: "/VbakSet",

                                                                template: oItemTemplate,

                                                                filters: filters

                                                });

                                   //Logic to get the row count

var tab = this.getView().byId("idVbakTable");

                                                //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; “ Here I am getting Error – Not able to read the length

                                                console.log(" >> ", rowCount);

                                                alert(rowCount);

                                },

I have tried with various methods, but not able to get the simple row count.

Accepted Solutions (0)

Answers (2)

Answers (2)

junwu
Active Contributor
0 Kudos

probably the timing. can you run the same code in onafterrendering

saivellanki
Active Contributor
0 Kudos

Kishore,

Everything looks fine. Does your model has a name?

Try to check the console for 'data' variable:


var data = model.getProperty(bindingPath);

console.log(data);

Regards,

Sai Vellanki.

0 Kudos

Hi Sai Vellanki,

I have checked in Console, there is no value returned for data.

Data is undefined and it has no value.

I could able to see the table rows under

oModel.oData

oData contains the no.of.rows. but how to get the row count.

Regards

Kishore.

saivellanki
Active Contributor
0 Kudos

Kishore,


Try:


oModel.oData.length;

Regards,

Sai Vellanki.