cancel
Showing results for 
Search instead for 
Did you mean: 

binding cells to sap.m.table

0 Kudos

Hi All , I'm using sap.m.table and i have to bind it cell by cell

there is my code in debugger

capture.png

Any Help please !

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Dear All , thanks for your answers

Like you've said the binding it's completely wrong but likely it works now I've found the solution

there is my code :

	var oModel1 = this.getOwnerComponent().getModel();
			var oFilter = new sap.ui.model.Filter("IdQuery", sap.ui.model.FilterOperator.EQ, sQuery);
			oModel1.read("/LinesSet", {
				filters: [oFilter],
				urlParameters: {
					"$expand": "ToCells"
				},
				success: function(oData) {
					var rows = [];


					console.log(oData.results.length + "length line ");
					// debugger;
					for (var i = 0; i < oData.results.length; i++) {


						var cells1 = {};


						for (var j = 0; j < oData.results[i].ToCells.results.length; j++) {


							console.log(oData.results[i].ToCells.results[j].Value);
							cells1["COL" + j] = oData.results[i].ToCells.results[j].Value;


						}
						rows.push(cells1);


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


					oModelX.setData({


						rows: rows
					});
					oTable.setModel(oModelX);


					oTable.bindItems("/rows", function(index, context) {
						var obj = context.getObject();
						var row = new sap.m.ColumnListItem();


						for (var k in obj) {
							row.addCell(new sap.m.Text({
								text: obj[k]
							}));
						}


						return row;
					});
					oTable.rerender();
					oTable.setBusy(false);
				},
				error: function(oError) {
					oTable.setBusy(false);
					console.log("erroooooooooor expand");
				}
			});

Best Regards

junwu
Active Contributor
0 Kudos

i don't know where u learn the ui5......you are really going a different way.....kind of nonsense

0 Kudos

thanks for your encouragement but I'm beginner and I'm trying hard to learn it

Answers (2)

Answers (2)

junwu
Active Contributor
0 Kudos

just look at some sample table code, the way you are doing is completely wrong.

review what is aggregation binding

former_member365727
Active Contributor
0 Kudos

you cannot use bind aggregation as the data retrieved using normal AJAX call in line 122.

Bind aggregation is possible only with oData or JSON model binding

junwu
Active Contributor
0 Kudos

I think he has the odata. (by looking at the name oData.results)

former_member365727
Active Contributor
0 Kudos

Hi Jun, yes you are correct, binding is done incorrectly

Congrats for becoming member of the month 🙂

junwu
Active Contributor
0 Kudos

thanks:)

..