リストに一意の値のみを表示しようとしています。 >>私はsap.m.ListBindingクラスとその機能getDistinctValues(sPath)
に走った可能性のある解決策を探している間sap.m.Listに一意の値を表示
{"Customers": [
{"name": "Customer A","age": "30"},
{"name": "Customer B","age": "25"},
...
]}
:値は、次のようなJSONモデルからロードされていると私はすべてのユニークな名前でリストを移入する必要があります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には、配列を指すPathが必要です。 – schnoedel