Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

sapui5 - How to send $filter query functions on DateTimeOffset values in UI5?

After some Googling, I figured I need the URL to be

...$filter=year(DateTimeProperty) eq 1990

I am not so sure how to achieve such a filter query using sap.ui.model.Filter in UI5.

Any help is appreciated.

question from:https://stackoverflow.com/questions/66046891/how-to-send-filter-query-functions-on-datetimeoffset-values-in-ui5

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can create the filter like this:

const oFilter = new sap.ui.model.Filter("year", sap.ui.model.FilterOperator.EQ, "1990");

There are multiple ways how to use this filter. If you have an element which is already bound:

this.byId("sListId").getBinding("items").filter(oFilter);

Obviously you need to adjust the id and binding. Or you can create a new binding where you pass the filter to the constructor

new sap.ui.model.odata.v4.ODataListBinding(oModel, sPath, oContext, vSorters, vFilters, mParameters)

Here is the API for OData v4 Listbindings https://sapui5.hana.ondemand.com/1.86.0/#/api/sap.ui.model.odata.v4.ODataListBinding%23methods/filter and here is some documention about filter and OData V4 https://sapui5.hana.ondemand.com/1.86.0/#/topic/426ff318051a465191c861b51a74f00e


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...