cancel
Showing results for 
Search instead for 
Did you mean: 

SAP UI5 Dynamic Input of Token into Smart Table Multiinput SmartFilter

emil_lazarski
Explorer

Hi,

I have an issue with the:

sap.ui.comp.smartfilterbar.SFBMultiInput

The scenario is following:

In a specific scenario I would like to add a new Token to the Multiinput of Smart Table SmartFIlter Bar. 

Hence I prepared the following code: 

 

 

 

let oFilterBar = this.getView().byId("ZZZ--listReportFilter");
var aFilterItems = oFilterBar.getAllFilterItems();
const _ProductIndex = aFilterItems.findIndex(item => item.mProperties.name === 'Product');
let oEVControl = aFilterItems[_ProductIndex].getControl();
oEVControl.removeAllTokens();
let _newToken = new sap.m.Token({
                    key: VALUE.toString(),
                    text: VALUE.toString()
                });
oEVControl.addToken(_newToken);

 

 

 

This is my understanding how one should be able to clear the filter and add new Tokens there. 

However, the problem is as follows:

1. Tokens are not removed with .removeAllTokens().

2. Adding tokens with .addToken(_newToken) may add it as a value but running the app does not reflect a filter (all records are displayed regardless of the added filter). 

3. There is no documentation for sap.ui.comp.smartfilterbar.SFBMultiInput. There is for: 

https://sapui5.hana.ondemand.com/#/entity/sap.ui.comp.smartfilterbar.SmartFilterBar

and for:

https://sapui5.hana.ondemand.com/#/entity/sap.m.MultiInput

I guess that the statement in sap.m.Multiinput is the answer to the problem:

  • Creating tokens in the control does not automatically update the model to which the "tokens" aggregation of the control is bound, no matter if the binding mode is set to "TwoWay". This is left to the application logic (check the corresponding sample).

but there are not details presented there. 

 

Thanks for hints.

 

View Entire Topic
emil_lazarski
Explorer

OK, so apparantly I found a workaround

1. To clear values :

getControl().setValue(''); // no comments...
2. To add tokens:
to add tokens use setTokens(aTokens) and not addToken; // no comments...