Sapui5 设置包含所有关键元素的MultimboBox

Sapui5 设置包含所有关键元素的MultimboBox,sapui5,Sapui5,我有一个多mbobox,我想用json中的所有键绑定多mbobox。iam使用XML视图。 我需要具有productId、name、category、suppliername等值的MultimboBox。如下所示 我的xml视图是 <MultiComboBox selectionChange="handleSelectionChange" selectionFinish="handleSelectionFinish" width="300px" items="{

我有一个多mbobox,我想用json中的所有键绑定多mbobox。iam使用XML视图。 我需要具有productId、name、category、suppliername等值的MultimboBox。如下所示

我的xml视图是

<MultiComboBox selectionChange="handleSelectionChange" selectionFinish="handleSelectionFinish" width="300px"  
  items="{  
                    path: '/Collection',  
                     sorter: { path: 'Name' }  
                }">  

  <core:Item key="{ProductId}" text="{Name}" />  
        </MultiComboBox> 
我认为,如果不创建新的数据对象(原始对象的键将转换为值),就不可能完成您要求的操作

下面是我将如何做到这一点(尽管我不经常使用xml视图):


在控制器中,我们创建一个新对象和模型:

var-oModelData={};
oModelData.data=[];
for(oData.Collection[0]中的var键){
var oObj={};
oObj.value=键;
omodedata.data.push(oObj);
}
setModel(新的sap.ui.model.json.JSONModel(oModelData));

下面是一个工作的JSBIN示例:

可能没有抓住要点,但是您发布的原始代码应该可以正常工作。您到底想要什么?

我创建了相同的想法,但我需要在组合框中输入productId、Name、Supplier Name。。。我想要的是这些东西,而不是价值观。@sarathchambayil看看更新后的答案。我不清楚你到底想要什么。很抱歉,我创建了另一个对象,就像你说的那样
{
  "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"
  }
  ]
}