Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3441

Sorting MultiComboBox

$
0
0

Hi there,

 

I got a question regarding on how to sort a (Multi)Combobox, since I start to run out of ideas.

I manually add the items to the list, since I want to eliminate duplicates read from the mapped model and there is no option for "distinct" selection in OData. Hence, I add an "emtpy" Multicombobox to my XML view

 

<MultiComboBox id="matTypeBox" name="MATNR" selectionFinish="onFilter" width="15em" xmlns="sap.m"/>

According to Sap Help, Sorting and Filtering works something like the following for UI Items with aggregation binding:

 

var oSorter = new sap.ui.model.Sorter("name", true); // sort descending
oComboBox.getBinding("items").sort(oSorter)

However, since I manually "filter" for duplicates, there is no binding set for the ComboBox. Is it possible to sort an aggregation on its key manually utilizing something like this or does manually filtering for duplicates imply that I also 'd have to sort the list "by hand". E.g. coding something similar to

 

oComboBox.getAggregation("items").sort(oSorter)

 

Background: the combo-box is used to filter a table which is bound to an OData Service. The Combobox filters the table on values that are not displayed in the table. When bound directly to the model, the combobox displays multiple duplicate values as well as many empty strings. Since there is no "distinct" filtering/ reading for OData models (at least as far as I know), I manually initialize the Combobox items by looping over the model, ignoring empty values and checking against the already added items to eliminate duplicates. The resulting list is ordered according to the table - I'd like it to be alphabetical.

 

Best regards

Christoph


Viewing all articles
Browse latest Browse all 3441

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>