Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

ComboBox Sorter unique output?

$
0
0

Hello everybody,

 

I'm currently trying to find a way to have a sap.ui.model.Sorter that sorts my output uniquely so that I don't have the same entry twice in my ComboBox, but so far without luck.

My scenario is that I receive some content from an OData model and try to bind it to a ComboBox. Sorting the entries works fine, but I have multiple entries, e.g. 2013, 2013, 2012 which I don't want (it should be 2013 only once and then 2012). I though that enabling grouping should fix that, but this is not the case.

I also tried the suggestion from the Demo Kit to replace the last "true" with "function (oContext) { oContext.getProperty("date").getYear(); }", but without luck.

Does anyone know if there's a possibility to uniquely output the sorter results or if I need to change something in the binding, the model...?

Thanks in advance!

 

Here's my sample code:

 

 

var oLabelYear = new c.Label({     text: oBundle.getText("Year")
});
var oComboBoxYear = new c.ComboBox();
// Add the other years from DB
oComboBoxYear.setModel(oModel);
var oYearTemplate = new sap.ui.core.ListItem();
oYearTemplate.bindProperty("text", "Year");
oComboBoxYear.bindItems("/Turnover",      oYearTemplate,      new sap.ui.model.Sorter("Year", true, true)); // Works, but doesn't sort uniquely

Viewing all articles
Browse latest Browse all 6178

Trending Articles



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