cancel
Showing results for 
Search instead for 
Did you mean: 

Set MulticomboBox with all key elements

Former Member
0 Kudos

hi all,

i have a multicomboBox and i want to bind the multicomboBox with all the keys in json. iam using XML view.

i need multicomboBox with values as productId, name, category,suppliername ..as follows

my xml view is


<MultiComboBox selectionChange="handleSelectionChange" selectionFinish="handleSelectionFinish" width="300px"

  items="{

                    path: '/Collection',

                     sorter: { path: 'Name' }

                }">

               

  <core:Item key="{ProductId}" text="{Name}" />

  <!-- Object.keys(path); -->

  </MultiComboBox>

my json file is


{

  "Collection": [

  {

  "ProductId": "1",

  "Name": "A",

  "Category": "Projector",

  "SupplierName": "Titanium",

  "Description": "A very powerful projector with special features for Internet usability, USB",

  "WeightMeasure": 1467,

  "WeightUnit": "g",

  "Price": 856.49,

  "CurrencyCode": "EUR",

  "Status": "Available",

  "Quantity": 3,

  "UoM": "PC",

  "Width": 51,

  "Depth": 42,

  "Height": 18,

  "DimUnit": "cm"

  },

  {

  "ProductId": "2",

  "Name": "B",

  "Category": "Graphics Card",

  "SupplierName": "Technocom",

  "Description": "Gladiator MX: DDR2 RoHS 128MB Supporting 512MB Clock rate: 350 MHz Memory Clock: 533 MHz, Bus Type: PCI-Express, Memory Type: DDR2 Memory Bus: 32-bit Highlighted Features: DVI Out, TV Out , HDTV",

  "WeightMeasure": 321,

  "WeightUnit": "g",

  "Price": 81.7,

  "CurrencyCode": "EUR",

  "Status": "Discontinued",

  "Quantity": 10,

  "UoM": "PC",

  "Width": 34,

  "Depth": 14,

  "Height": 2,

  "DimUnit": "cm"

  },

  {

  "ProductId": "3",

  "Name": "C",

  "Category": "Graphics Card",

  "SupplierName": "Red Point Stores",

  "Description": "Hurricane GX: DDR2 RoHS 512MB Supporting 1024MB Clock rate: 550 MHz Memory Clock: 933 MHz, Bus Type: PCI-Express, Memory Type: DDR2 Memory Bus: 64-bit Highlighted Features: DVI Out, TV-In, TV-Out, HDTV",

  "WeightMeasure": 588,

  "WeightUnit": "g",

  "Price": 219,

  "CurrencyCode": "EUR",

  "Status": "Out of Stock",

  "Quantity": 25,

  "UoM": "PC",

  "Width": 34,

  "Depth": 14,

  "Height": 2,

  "DimUnit": "cm"

  },

  {

  "ProductId": "4",

  "Name": "D",

  "Category": "Accessory",

  "SupplierName": "Technocom",

  "Description": "Web camera, color, High-Speed USB",

  "WeightMeasure": 700,

  "WeightUnit": "g",

  "Price": 59,

  "CurrencyCode": "EUR",

  "Status": "Available",

  "Quantity": 22,

  "UoM": "PC",

  "Width": 18,

  "Depth": 19,

  "Height": 21,

  "DimUnit": "cm"

  },

  {

  "ProductId": "5",

  "Name": "E",

  "Category": "Accessory",

  "SupplierName": "Technocom",

  "Description": "Lock for Monitor",

  "WeightMeasure": 40,

  "WeightUnit": "g",

  "Price": 13.49,

  "CurrencyCode": "EUR",

  "Status": "Available",

  "Quantity": 30,

  "UoM": "PC",

  "Width": 11,

  "Depth": 11,

  "Height": 3,

  "DimUnit": "cm"

  }

  ]

}

Accepted Solutions (0)

Answers (2)

Answers (2)

saivellanki
Active Contributor
0 Kudos

Hi Sarath,

Use parts object while binding to text/key of item. Check this sample: JS Bin - Collaborative JavaScript Debugging

API - JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.base.ManagedObject

Regards,

Sai Vellanki.

vijay_kumar49
Active Contributor
0 Kudos

var mcb = new sap.m.MultiComboBox({

  id : "mcb",

  items : {

    path : "/items",

    template : oItemTemplate

  },

  selectedKeys : {  <--- here

    path : "/selected",

    template : "{selected}"

  }

});

Please check the Example

Former Member
0 Kudos

i am using xml view

vijay_kumar49
Active Contributor
0 Kudos

Please try this

SAPUI5 Explored


<mvc:View

  height="100%"

  xmlns:core="sap.ui.core"

  xmlns:mvc="sap.ui.core.mvc"

  xmlns="sap.m">

  <Page showHeader="false">

  <content>

  <MultiComboBox

  items="{

  path: '/ProductItems',

  sorter: { path: 'Name' }

  }">

  <core:Item key="{ProductId}" text="{Name}" />

  </MultiComboBox>

  </content>

  </Page>

</mvc:View>

controller:

onInit: function () {

  // set explored app's demo model on this sample

  var oModel = new sap.ui.model.json.JSONModel("JSON Path");

  this.getView().setModel(oModel);

  }

Former Member
0 Kudos

i don't want all productId or name.. i want dropdown with keys as values for example when i click comboBox i should have options like productId, name,category supplierName so on..

in short i want keys to get displayed on the comboBox

vijay_kumar49
Active Contributor
0 Kudos

did you look at the this link SAPUI5 Explored

Former Member
0 Kudos

yes. i tried it from that only, but its displaying the vaues not the key

vijay_kumar49
Active Contributor
0 Kudos

in dropdown what do you want display? Key or Value ?

Former Member
0 Kudos

key