0
我試圖在列表中只顯示唯一值。該值從以下JSON模式加載,我需要與所有唯一的名稱來填充列表:在sap.m.List中顯示唯一值
{"Customers": [
{"name": "Customer A","age": "30"},
{"name": "Customer B","age": "25"},
...
]}
在尋找一個可能的解決方案我跑進sap.m.ListBinding類及其功能getDistinctValues(sPath)
>>see API
該函數應該從給定的相對路徑返回一個不同值的數組。我試過以下方式使用該功能:
var oModel = this.getView().getModel("customers"),
oListBinding = new ListBinding(oModel, "customers>Customers", oModel.getContext("/Customers")),
arrValues = oListBinding.getDistinctValues("name");
但是我總是收到arrValues=null
。任何想法,我在做什麼錯在這裏? 我也試過使用customers>name
,customers>/name
和/name
沒有任何運氣。
你嘗試過'新的ListBinding(oModel,「/ Customers」)'?或者'如果你想使用上下文,新的ListBinding(oModel,「」,oModel.getContext(「/ Customers」))'' ListBinding應該有一個指向數組的路徑。 – schnoedel