on 06-01-2015 11:10 AM
Hello All,
I want to add a new value to sap.m.table via a JSON file using Bind Aggregation.
Code:
var oLbl1 = new sap.m.Label({
id : "idlabel", // sap.ui.core.ID
design : sap.m.LabelDesign.Standard, // sap.m.LabelDesign
text : "BARCODE", // string
visible : true, // boolean
textAlign : sap.ui.core.TextAlign.Begin, // sap.ui.core.TextAlign
textDirection : sap.ui.core.TextDirection.Inherit, //
width : '100%', // sap.ui.core.CSSSize
required : true, // boolean
});
var oInputBar = new sap.m.Input({
id:"idinput",
width:"100%"
});
var oModel = new sap.ui.model.json.JSONModel("Model/data.json");
var oTable = new sap.m.Table({
width:"100%"
});
oTable.addColumn(new sap.m.Column({}));
oTable.addColumn(new sap.m.Column({}));
var oTemplate = new sap.m.ColumnListItem({
type : sap.m.ListType.Active,
cells : [ new sap.m.Label({
text : "{SlNo}"
}), new sap.m.Label({
text : "{title}"
}) ]
});
oTable.setModel(oModel);
console.log(JSON.stringify(oModel.getData()))
oTable.bindAggregation("items", {
path : "/commodity",// <<<Your data path at runtime
template : oTemplate
});
var oSubmit1 = new sap.m.Button({
text : "Set",
width : "50%",
});
var oBack = new sap.m.Button({
text : "Back",
width : "50%",
});
var oUp = new sap.m.Button({
text : "PgUp",
width : "50%",
});
var oDown = new sap.m.Button({
text : "PgDn",
width : "50%",
});
oSubmit1.attachPress(function() {
var oInputBar1 = oInputBar.getValue();
var aData;
alert(oInputBar1);
var modelData = oModel.getData();
alert(JSON.stringify(modelData))
modelData.push({
"SlNo" : aData
});
// _________________DATA PUSH TO MODEL
var oModel1 = oModel.setData({
modelData : aData
}); // SET MODEL
});
var modelData = oModel.getData();
alert(JSON.stringify(modelData))
modelData.push({
SlNo : aData
});
and do bind aggregation,
var oModel1 = oModel.setData({
modelData : aData
}); // SET MODEL
})
oTable.setModel(oModel1);
console.log(JSON.stringify(oModel.getData()))
oTable.bindAggregation("items", {
path : "/commodity",// <<<Your data path at runtime
template : oTemplate
});
;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
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.