How to filter DateTime data using sap.ui.model.Filter?

混江龙づ霸主 提交于 2019-12-25 18:38:07

问题


I've tried to filter DateTime data using sap.ui.model.Filter:

oTableSearchState = [new Filter([ new Filter("Date", FilterOperator.Contains, sQuery), new Filter("Another_Date", FilterOperator.Contains, sQuery), ])]

it return 400 Bad String. I found that the odata request is ...$filter substringof(,Date). So I know it's not correct that using a "string filter" to filter date.

what I need is ...$filter= Date ge datetime'2016-08-17T16:00:00Z' and Date lt datetime'2016-08-18T16:00:00' Can I do that with sap.ui.model.Filter? Or the only way to do that is put filter parameters together by my own hands?


回答1:


Yes you can, please use sap.ui.model.Fitler as (using operator BT):

new sap.ui.model.Filter("Date", sap.ui.model.FilterOperator.BT, dateFrom, dateTo)

Selection of dates can be done by handling sap.m.DateRangeSelection event "change"

handleChange : function(oEvent){
        dateFrom = oEvent.getParameter("from");
        dateTo   = oEvent.getParameter("to");
}


来源:https://stackoverflow.com/questions/41736210/how-to-filter-datetime-data-using-sap-ui-model-filter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!