cancel
Showing results for 
Search instead for 
Did you mean: 

Could binding hierarchical aggregations?

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

saivellanki
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

Thanks so much.

Answers (0)