Skip to Content

binding cells to sap.m.table

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 !

capture.png (44.0 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Apr 07, 2017 at 09:45 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 06, 2017 at 05:42 PM

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

    review what is aggregation binding

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 06, 2017 at 05:26 PM

    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

    Add comment
    10|10000 characters needed characters exceeded