Skip to Content
0
Jun 11, 2020 at 09:23 AM

sap ui5 - Sap.m.table - checkbox click does not gets selected in model

277 Views Last edit Jun 11, 2020 at 09:38 AM 3 rev

debugger.pngfront-end-view.pngHello All,

I am using sap.m.table with 3 columns out of which one column has checkbox option. Other two columns are input fields. I am binding whole table to model but when I click on Checkbox it does not show up in the model . It works for other input fields but not for checkbox. Please help if you are aware of any such issue.

Code in controller init--

var data = { "Materials": [{ }] };

var oModel = new sap.ui.model.json.JSONModel();

oModel.setData(data);

this.getView().setModel(oModel, "jTabModel");

Please find attachment for Code for fragment ..

fragment.txt

On onAddMaterial event , below code is added

onAddMaterial: function () {

var oTable = this.getView().byId("idMaterialsTable");

var oTableModel = oTable.getModel("jTabModel").getProperty("/Materials");

var oNewRow = {};

oTableModel.push(oNewRow);

oTable.getModel("jTabModel").setProperty("/Materials", oTableModel); },

On save event of main view, I have added below code.

var oTable = this.getView().byId("idMaterialsTable");

var oModel = this.getView().getModel();

oModel.setUseBatch(true);

var jModel = oTable.getModel("jTabModel").getProperty("/Materials");

for (var i = 0; i < jModel.length; i++) {

var oEntry = jModel[i];

oModel.create("/ZTEST_Material_EntrySet", oEntry, { method: "POST", success: function (data) { }, error: function (e) { } }); }

Over here i dont get value for checkbox in oEntry. I get below data in debugger.

Attachments

debugger.png (13.4 kB)
fragment.txt (1.3 kB)