Convert Token from ValueHelpDialog into Filters in SAPUI5

Viewed 1226

I am using a ValueHelpDialog with range support. So these tokens are generated based upon selection and values entered. e.g. For 'contains' a Token like *abc* is generated and for 'equal to', =abc is generated. These tokens can be fetched on clicking OK on the ValueHelpDialog as seen below.

enter image description here

I need to create a sap.ui.model.Filter for these selections. How can I evaluate the Tokens to retrieve FilterOperator and the value to be filtered?

Kindly assist, Thanks!

2 Answers

You can retrieve the filter data from the token with the data function.

const oProperties = oToken.data("range");
/*
{
  exclude: false,
  operation: "Contains",
  keyField: "PROPERTY_PATH",
  value1: "abc",
  value2: null
}
*/

const oFilter = new Filter({
  path: oProperties.keyField,
  operator: FilterOperator[oProperties.operation],
  value1: oProperties.value1
});

We can directly get the operator. Follow below steps to get it onclick of ok button on valuehelp dialog.

  1. oEvent.getParameters().tokens
  2. expand the result of above step and go to maggregations->customdata
Related