Skip to Content
0
Feb 12, 2019 at 03:01 PM

sapui5 binding rows of table doesn't work

2317 Views

Hi,

I found a lot of pages concerning my issue. but despite trying every single solution I found,

it doesn't work. since I'm locked for several days, I ask your advice.

here is a part of my View :

	<App id="mainApp">
		<pages>
			<Page id="detail" title="Contrats" class="sapUiStdPage">
				<content>
					<Table id="table1" noDataText="Vous n'avez aucun Compte." alternateRowColors="true" items="{/oDataAccount}">
						<items>
							<ColumnListItem type="Active" id="item1">
								<cells>
									<Text text="{Vkont}" id="text3"/>
									<Text text="{Gpart}" id="text4"/>
									<Text text="{Formkey}" id="text5"/>
								</cells>
							</ColumnListItem>
						</items>

I'm trying to use aggregation to have one line of table for one record in oData service.

here is my controller View :

		onInit: function () {
			// Get the Router Info
			var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
			if (oRouter) {
				oRouter.getRoute("Main").attachMatched(this._onRouteFound, this);
			}
		},
		_onRouteFound: function (oEvent) {
			var oArgument = oEvent.getParameter("arguments");
			oPartnerProd = oArgument.G_PartnerProd;
			oPartnerResp = oArgument.G_PartnerResp;
			var sPath = "/InfoProdSet(PartnerResp='" + oPartnerResp + "',PartnerProd='" + oPartnerProd + "')/ACCOUNTSet";
			this.oModel = this.getOwnerComponent().getModel("tableData");
var testTable = this.byId("table1");

			this.oModel.read(sPath, {
				success: function (oData) {
					debugger;
					var oDataAccount = new sap.ui.model.json.JSONModel(oData);
					oDataAccount.setData(oData);
					testTable.setModel(oDataAccount);
					testTable.bindAggregation("items", {
						path: "/d/results",
						template: testTable.getBindingInfo("items").template
							//filters: []    if you have filters set them here !!!
					});
});
}

oData works fine. here is corresponding json format anwer :

{
  "d" : {
    "results" : [
      {
        "__metadata" : {
          "id" : "<Serveur>/sap/ZOA_SOLAIRE_PROJ_SRV/ACCOUNTSet(Vkont='210000008',Gpart='3000064')",
          "uri" : "<Serveur>/sap/opu/odata/sap/ZOA_SOLAIRE_PROJ_SRV/ACCOUNTSet(Vkont='210000008',Gpart='3000064')",
          "type" : "ZOA_SOLAIRE_PROJ_SRV.ACCOUNT"
        },
        "Vkont" : "210000008",
        "Gpart" : "3000064",
etc...

I tried a lot of combinations (when I say a lot, it's a lot) and nothing works.

a little precision because I think it's worth saying, i'm working with a model "tableData" and not with default one :

here is an extract from manifest :

		"models": {
			"i18n": {
				"type": "sap.ui.model.resource.ResourceModel",
				"settings": {
					"bundleName": "Oa_solaire_port.Oa_solaire_port.i18n.i18n"
				}
			},
			"tableData": {
				"uri": "/sap/opu/odata/sap/ZOA_SOLAIRE_PROJ_SRV/",
				"type": "sap.ui.model.odata.v2.ODataModel",
				"settings": {
					"defaultOperationMode": "Server",
					"defaultBindingMode": "OneWay",
					"defaultCountMode": "Request"
				},
				"dataSource": "ZOA_SOLAIRE_PROJ_SRV",
				"preload": true
			}
		},

what path should I use in binding aggregation ?

what path in View for fields ?

thanks in advance.