I am deploying over gateway with UI5 version 1.28 and my model is defined in controller and am able to get records in table from json. I am trying to get the number of records displayed in table on the load. I am able to do that on click of a button via sap.ui.getCore().byId("oTable").getModel("MyJsonData").oData.length
but I want to get this without an action and on load only. Tried calling the same at init of controller but it does not work and returns undefined.
Tried few other options as below
sap.ui.getCore().getModel("MyJsonData").oData.lengthvia = undefined.
sap.ui.getCore().byId("oTable").getRows().length - does not work.
_getRowCount() - does not work
oTable.getBinding().getLength() - does not work
Anything else to try?
My code is as below: In View:
var oTable = new sap.ui.table.Table("oTable",{
selectionMode : sap.ui.table.SelectionMode.Single,
selectionBehavior : sap.ui.table.SelectionBehavior.Row,
visibleRowCount : 7,
firstVisibleRow : 3,
rowSelectionChange:oController.formatTable,
fixedColumnCount : 2
});
oTable.bindRows("MyJsonData>/");
Inside Component.js
var oModel = new sap.ui.model.json.JSONModel("model/data.json");
this.setModel(oModel, "MyJsonData");
getRows
. Please, show us some more code. – Boghyon Hoffmann