cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

UI5: Dynamic filtering on ui.Table at load time

mandrew
Explorer
0 Kudos
1,284

I have a ui.Table that I want to filter by date, defaulting to six months in the past when the user opens the view.

Building the filter in javascript is easy enough, but I can't put the filter code in the view's init because the binding hasn't been created yet. Tying it to metadataLoaded isn't the right timing either. Is there a "bound" event somewhere that I'm missing in the documentation?

I tried putting the filter in the view XML, but I can't figure out how to put a dynamic date in the filter expression in the path, and the filter in XML doesn't support binding so I can't supply the "from" date that way.

So how can I filter the table using a dynamic date value without the user needing to trigger an event to cause it?

Accepted Solutions (1)

Accepted Solutions (1)

junwu
SAP Champion
SAP Champion
0 Kudos

https://blogs.sap.com/2021/03/23/ui5-tips-use-of-binding-suspend/

you can follow this blog, initially suspend the binding, once you set the filter, you can resume the binding

mandrew
Explorer
0 Kudos

Promising, but I still have the timing problem - code run through onInit runs before the binding specified in the XML is created, so I still can't get to the suspended binding to attach filters and resume it without a user-triggered event to do it.

junwu
SAP Champion
SAP Champion
0 Kudos

how about adding the code in onafterrendering? it may help.

mandrew
Explorer
0 Kudos

That's the missing piece! Thank you!

Answers (0)