Skip to Content
author's profile photo Former Member
Former Member

Dynamic binding of items in sap.m.Table using JS views

HI,

I am developing a master detail page for a Purchase Order application. In master page, i display the list of Purchase Orders & on clicking the PO, i should display the detail page.

We use different ODATA models for Master & detail page. I am able to successfully list the POs in master page & i am struggling on the part where i have to pass the selected PO number to the new ODATA service URL & then display the details in a table.

Below is the code i use on TAP of Purchase order from master page:

tap: function(oEvent)

{

sap.ui.getCore().byId("PODetailstable_nodata_id").setVisible(false);

var oContext=oEvent.getSource().getBindingContext();

var odataModel_PO_detail = new sap.ui.model.odata.ODataModel(detailServiceUrl,false, "dev_sde", "28aug@2013");

odataModel_PO_detail.setCountSupported(false);

var tappedPONumber= oContext.getProperty("PONumber");

var path = "/POHeaderSet('"+tappedPONumber+"')/HDRtoITM";

PO_DetailsPage.setBindingContext(oContext);

sap.ui.getCore().byId("po_details_table_id").setModel(odataModel_PO_detail);

sap.ui.getCore().byId("po_details_table_id").bindContext(path);

sap.ui.getCore().byId("po_details_table_id").setVisible(true);

},

And below is the code of my Detail page & the table: I set the bindcontext with new path at "tap" function in master page, i also do bindaggregation for the table with the new path.

The issue is i am able to HIT the new service URL, but no data is displayed. There is also a demo application on the same, but w/o source code it doesnt help me much in resolving this issue.

var PODetailstable_nodata = new sap.m.Table("PODetailstable_nodata_id",{title : "No Data"});

var po_details_table = new sap.m.Table("po_details_table_id", {

inset: true,

headerText: "table for Detail page",

columns: [

new sap.m.Column({

header: new sap.m.Label({ text: "PO Number" }) }),

new sap.m.Column({ header: new sap.m.Label({ text: "Vendor" }) }),

new sap.m.Column({

header: new sap.m.Label({ text: "Vendor Name" }) }),

],

});

var oTemplate = new sap.m.ColumnListItem({

cells: [

new sap.m.Text({ text: "{PoNumber}" }),

new sap.m.Text({ text: "{Vendor}" }),

new sap.m.Text({ text: "{VendorName}"})

]

});

po_details_table.bindAggregation("items", {

path:"/POHeaderSet('"+"{PONumber}"+"')/HDRtoITM",

template: oTemplate

});

var PO_DetailsPage = new sap.m.Page("PO_DetailsPage_id",

{

// title : "Purchase Order Details",

title : "{PoNumber}",

content : [

PODetailstable_nodata,

po_details_table,

],

footer : new sap.m.Bar

({

contentRight: [

new sap.m.Button({

text : "Approve",

//press: oController.approve_pr,

}

)

],

}

),

});

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jul 28, 2014 at 08:31 AM

    If you look at my code i would have set the path in two places:

    1. at tap of PO number from master page:

    sap.ui.getCore().byId("po_details_table_id").bindContext(path);

    2. at bindaggregation of sap.m.table at details page.

    po_details_table.bindAggregation("items", {

    path:"/POHeaderSet('"+"{PONumber}"+"')/HDRtoITM",

    template: oTemplate

    });

    I am not sure if this is the right way of passing parameters dynamically to the ODATA URL? Appreciate any answers regarding to this. There is a demo application on Purchase order similar to my scenario, but i couldnt find any source code related to it.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Monalisa Biswal

      Hi Monalisa,

      Thanks much for your reply. The issue was fixed. Earlier, i was getting bindingcontext from master page & was trying to set the same in the detail page as well. Now, if you see i am actually setting the new path required for detail page & appending the clicked PO number to it.This worked fine.

      updateBinding: function(oEvent)

      {

      var detailServiceUrl = "proxy/http/incas1054.ind.cldsvc.accenture.com:8000/sap/opu/odata/sap/ZPURCHASE_PAY_SRV";

      var odataModel_PO_detail = new sap.ui.model.odata.ODataModel(detailServiceUrl,false, "dev_sde", "28aug@2013");

      odataModel_PO_detail.setCountSupported(false);

      var tableView=sap.ui.getCore().byId("po_details_table_id");

      tableView.setModel(odataModel_PO_detail);

      //alert(tableView.getModel());

      var oContext = tableView.getBindingContext();

      /*tableView.bindElement("/POHeaderSet");

      alert(oContext);*/

      var tappedPONumber= oContext.getProperty("PONumber");

      var path= "/POHeaderSet('"+tappedPONumber+"')/HDRtoITM";

      var oTemplate = new sap.m.ColumnListItem({

      cells: [

      new sap.m.Text({ text: "{PoItem}"}),

      new sap.m.Text({ text: "{MaterialDesc}" }),

      new sap.m.Text({ text: "{DeliveryDate}" }),

      new sap.m.Text({ text: "{Quantity}"}),

      new sap.m.Text({ text: "{NetPrice}"}),

      ]

      });

      tableView.bindItems(path, oTemplate);

      },

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.