如何将2个数据模型源传递给SearchField

时间:2019-07-09 09:11:03

标签: javascript sapui5 sap

我想通过两个部分将数据从2个源传递到Searchfield控件,如此处的示例所示。 https://openui5.hana.ondemand.com/#/topic/dfe04650afc046e0802abb1a1a90d2d9

我的代码:

var input = JsonConvert.DeserializeObject<Dictionary<string, string>[]>(@"
[
  {
    ""2"": ""a"",
    ""3"": ""a""
  },
  {
    ""2"": ""f"",
    ""3"": ""a"",
    ""4"": ""p""
  },
  {
    ""2"": ""n"",
    ""3"": ""o"",
    ""4"": ""t""
  }
]");

var result = input
    .SelectMany(d => d.OrderBy(kvp => kvp.Key).Select(kvp => kvp.Value))
    .Select((value, index) => new {index, value})
    .ToDictionary(iv => iv.index, iv => iv.value);

 var jsonResult = JsonConvert.SerializeObject(result);

此操作失败,并显示以下跟踪信息

<SearchField
    id="mySFID"
    enableSuggestions="true"
    search="onSelectDiseaseTerm"
    suggest="onSuggestDiseaseTerm1"
    suggestionItems="{
    parts : [
        {path: 'db2>/SOURCE1/'},
        {path: 'db2>/SOURCE2/'}],
    type: 'sap.m.SearchField'}" >
<suggestionItems>
    <SuggestionItem
            text="{db2>DISEASE_TERM}"
            key="{db2>DISEASE_TERM}" />
</suggestionItems>
</SearchField>

1 个答案:

答案 0 :(得分:1)

SearchFieldsuggestionItems是将sap.m.SuggestionItem数组作为输入的聚合。您无法通过您想做的事情。