Skip to Content
0
Former Member
Jul 20, 2016 at 03:36 PM

How to load variantItems in FilterBar?

202 Views

There is great Variant Management Implementation Guide (http://scn.sap.com/docs/DOC-69965), where working example of VariantManagement with some functionality is described.

However, stand-alone VariantManagement is described there and this description is not enough in case for VariantManagement, which is inside FilterBar.

For example, in above mentioned description variant items are loaded from the model with the help of property "variantItems" in control "VariantManagement", however, such attribute does not help in control "FilterBar".

Following code does not show specified variant items:

var oFilterBar = new sap.ui.comp.filterbar.FilterBar({
  persistencyKey: "X",
  variantItems: [
    new sap.ui.comp.variants.VariantItem({"key": "key1", "text": "text1"}),
    new sap.ui.comp.variants.VariantItem({"key": "key2", "text": "text2"})
  ]
});

( see https://jsfiddle.net/5sow6gk6/)

And following code gives error "oFilterBar.addVariantItem is not a function":

var oFilterBar = new sap.ui.comp.filterbar.FilterBar({
  persistencyKey: "X"
});
oFilterBar.addVariantItem(
  new sap.ui.comp.variants.VariantItem({"key": "key1", "text": "text1"})
);

(see https://jsfiddle.net/3d1kwo2u/)

So, how variantItems can be loaded to VariantManagement inside FilterBar?