on 2019 May 14 1:25 PM
Hello All,
I am currently facing one issue, Can you please help me here?
I have Created one Dynamic table on click of Button,
First record is not Problem, But when I wamt to Push my Second record it is giving this error.
oModel.push is not a function,
My Code is Here
onChildAdd1:function(){
// Get Value from Screen
var oBSValue = this.getView().byId("BSValue").getValue();
var oGRO = this.getView().byId("GROValue").getValue();
var check1 = this.getView().byId("Button").getText();
if (check1 === "Add More"){
this.getView().byId("Button").setText("Add More Item");
var itemRow = {"gcn":[{BSValId: oBSValue, GROValId: oGRO}]};
var oTable = new sap.ui.table.Table({
id: "table1",
title: "Reasoncode and Ratetypes",
visibleRowCount: 7,
firstVisibleRow: 3,
selectionMode: sap.ui.table.SelectionMode.Single
});
//Define the columns and the control templates to be used
oTable.addColumn( new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "BSValue"}),
template: new sap.ui.commons.TextView().bindProperty("text", {path: "BSValId"}),
width: "400px"
}));
oTable.addColumn( new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "GROValue"}),
template: new sap.ui.commons.TextView().bindProperty("text", {path: "GROValId"}),
width: "400px"
}));
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(itemRow);
oTable.setModel(oModel);
oTable.bindRows("/gcn");
oTable.placeAt("__xmlview0--jobinfo1-Collapsed--packItem");
}
else {
// var oModel = new sap.ui.model.json.JSONModel();
// oModel.setData(itemRow);
var oTable = sap.ui.getCore().byId("table1");
var oModel = oTable.getModel().getProperty("/");
var itemRow = {"gcn":[{BSValId: oBSValue, GROValId: oGRO}]};
oModel.push("itemRow");
oTable.getModel().setProperty("/", oModel);
}
}
Regards,
Sujoy
Request clarification before answering.
Hi,
i think it is because in the "else", oModel is an object not an array.
var oModel = oTable.getModel().getProperty("/");
try,
var oModel = oTable.getModel().getProperty("/gcn");
var itemRow ={BSValId: oBSValue, GROValId: oGRO};
oModel.push("itemRow");
Regards,
Fabrice
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
70 | |
21 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.