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

Could binding hierarchical aggregations?

Hi all,

Now I want to bind the model to the first level aggregations —table and the second level aggregation — multiComboBox. But it seems not to work. Whether the binding method is wrong or any other way to binding? Thanks for any suggestion.

sap.ui.define([
      "sap/m/HBox",
      "sap/m/CheckBox",
      "sap/m/MultiComboBox",
      "sap/ui/model/json/JSONModel"
    ], function(HBox, CheckBox, MultiComboBox, JSONModel) {
      "use strict";
      
      var aData = {
        pms:
        [{label:'1',chekced:true,isOthers:true,others:
          [{label:'11'},{label:'12'}]},
        {label:'2',chekced:true,isOthers:true,others:
         [{label:'21'},{label:'22'}]},
        {label:'3',chekced:true,isOthers:true,others:
         [{label:'31'},{label:'32'}]},
        {label:'4',chekced:true,isOthers:true,others:
         [{label:'41'},{label:'42'}]},
        {label:'5',chekced:true,isOthers:true,others:
         [{label:'51'},{label:'52'}]}]
      };
      var oModel = new JSONModel();
      oModel.setData(aData);

      
      var oComboBox = new MultiComboBox({
        width: "200px",
        enabled: true,
        items:{
          path:'/others',
          templateShareable: false,
          template: new sap.ui.core.Item({
            text:"{label}"
          })
        }
      });
      
      var oCheckBox = new CheckBox({
        selected: "{/checked}",
        text:'{label}'
      });
      var template = new sap.m.ColumnListItem({
        cells:[
          oComboBox,
          oCheckBox
        ]
      });
      var table = new sap.m.Table({
        columns:[new sap.m.Column({header: new sap.m.Text({text:'col1'})}),
                new sap.m.Column({header: new sap.m.Text({text:'col1'})})]
      }).bindAggregation('items','/pms',template);
      table.setModel(oModel);
      var oHBox = new HBox({
        items: [table]
      });
      oHBox.placeAt("content");
    });

Thanks,

Mengchi

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Jul 20, 2016 at 06:41 AM

    Hi Mengchi,

    MultiComboBox 'items' binding path should be 'others'.

    var oComboBox = new MultiComboBox({  
        width: "200px",  
        enabled: true,  
        items:{  
           path:'others',  
           templateShareable: false,  
           template: new sap.ui.core.Item({  
             text:"{label}"  
            })  
          }  
        });
    

    Code updated and now it works fine: JS Bin - Collaborative JavaScript Debugging


    Regards,

    Sai.

    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.