cancel
Showing results for 
Search instead for 
Did you mean: 

Save the keys of a custom smart filter field

jthuijls
Participant
0 Kudos

Hi,

In the example here: https://sapui5.hana.ondemand.com/#/sample/sap.ui.comp.sample.smartfilterbar.example2/preview a custom field is defined with a `sap.m.Select` control inside. The smart filter bar recognises changes if a new key is selected, but on saving the variant or retrieving the variant, these keys are not restored.

What's the way to include the custom field's values in the variant?

Accepted Solutions (1)

Accepted Solutions (1)

mvaibhav
Contributor

Hi Jorg,

You have to do it manually as Smart Filter Bar will not automatically recognize these fields.

The SmartFilterBar offers two events that can be used to enable custom fields for variant management:

  • beforeVariantSave
  • afterVariantLoad

You can use the beforeVariantSave event to update the model of the SmartFilterBar with the values from the custom fields. Every value within the model is stored as a variant. The values of custom fields should be stored under the property _CUSTOM, for example,

oSmartFilter.setFilterData({ _CUSTOM :{field1:"abc", field2:"123"}});

You can use the event afterVariantLoad to get the values from the model and use them to update the custom filter fields, for example:

oData = oSmartFilter.getFilterData();
var oCustomFieldData = oData["_CUSTOM"];
oCustomField1.setValue(oCustomFieldData.field1);

If both events are handled this way, custom fields are enabled for variant management.

Thanks,

Vaibhav Maheshwari

priyankagayen
Employee
Employee
0 Kudos

Hi Vaibhav,

where have you declared the functions for these events??

Regards,

priyanka

mvaibhav
Contributor
0 Kudos

hi priyanka_gayen

The functions are declared in the controller.js file for the respective view where we have the smart filter bar.

Thanks,

Vaibhav Maheshwari

Answers (0)