cancel
Showing results for 
Search instead for 
Did you mean: 

Multicombox is not displaying tokens when value is selected from it.

0 Kudos

Hi all,

I have one array of data and I want to bind that data to multicombobox.

I have binded that data to Multicombobox using javascript as shown below.

The problem is when I select any value from multicombobox, tokens are not displaying as per the default behavior of the control.

Please help me in this. As per my guess, this array is not associative array (do not have keys and values.) this might have caused this issue.


Array:
{  
   "A":"Apple",
   "B":[  
      {  
         "key":1,
        "value":"ball",
         "fruits":[  
            "Apple",
            "Orange",
            "banana",
            "Guava"
            
         ]
      }
     
   ]
}

XML view:
<MultiComboBox id="MCBId" width="280px" class="sapUiTinyMarginTop" ></MultiComboBox>

Controller code:
var data = sap.ui.getCore().getModel("myModel").getData();
       var oModel = new sap.ui.model.json.JSONModel();
        oModel.setData(data);
        this.getView().setModel(oModel, "myModel");

       var fruitsArray = data.fruits[0].names;
        for(var i = 0; i<fruitsArray.length; i++){
           var fruitsDD;
            if(!fruitsDD){
           fruitsDD = this.getView().byId("MCBId");
              }         				
          var oCoreItem = new sap.ui.core.Item();
              oCoreItem.setText(fruitsArray[i]);
               oCoreItem.setKey(fruitsArray[i]);
                 fruitsDD.addItem(oCoreItem);
           }


Accepted Solutions (0)

Answers (0)