Skip to Content

How to change the items aggegation binding of an XML view at runtime

Based on some user action I want to refresh the list with new values.

I'm using an XML view, thus the 'template' of the items is defined in XML.

The following method expects a template as third parameter so it doesn't work.

oList.bindAggregation("items", "/CourseGroupSet(" + objid + ")/Nodes");

How can I simply change the path of the binding without having to redefine my template?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Sep 15, 2016 at 11:43 AM

    Hi Pieter,

    one approach can be this one:

    In the view assign an Id to the template:

    <ColumnListItem id="listTemplate">



    In the controller just get the template by id and re-use it as template:

    oList.bindAggregation("items", "/CourseGroupSet(" + objid + ")/Nodes", this.getView().byId('listTemplate'));

    Add a comment
    10|10000 characters needed characters exceeded

    • Just to get this straight.

      So in fact when I'm using an XML view where the binding is defined within the view (at first) it is not possible to alter the binding at runtime?

      PS. I'm using routing so rather than using init() I've put the bindItems call in the onBypassed as well as onRouterMatched (and the items attribute for the aggregation binding in the XML view is empty).

  • author's profile photo Former Member
    Former Member
    Posted on Sep 15, 2016 at 11:46 AM

    hi try this code.then u use dynamic binding

    In view

    <List id="list" swipe="lefttoright" items="{} ">

    <items> </items>


    Incontroller oninit:function(){

    ///// here create named model and bind like this.this it will work based on username ////////////////////////////

    var oTemplate = new sap.m.ObjectListItem({ type: sap.m.ListType.Active, id:"po", title: "{loginPage>Ebeln}", press:[that.onListItemPress, that ], attributes : [ new sap.m.ObjectAttribute( "ven",{ title:"Vendor", text : "{loginPage>Lifnr}", }) , new sap.m.ObjectAttribute({ title:"Amount" , text : "{loginPage>Value2}" }) , new sap.m.ObjectAttribute({ title:"Release code", text : "{loginPage>Frgco}" }) , new sap.m.ObjectAttribute({ title:"Description" , text : "{loginPage>Frgct}" }), ]




    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 16, 2016 at 10:22 AM

    Hi Pieter,

    Best way is to update the control model, instead of re-binding items.

    Will this sample help? JS Bin - Collaborative JavaScript Debugging



    Add a comment
    10|10000 characters needed characters exceeded

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.