如何使用sap.ui.model.Filter过滤DateTime数据? [英] How to filter DateTime data using sap.ui.model.Filter?

查看:290
本文介绍了如何使用sap.ui.model.Filter过滤DateTime数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用sap.ui.model.Filter过滤DateTime数据:

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), ])]

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

它返回400 Bad String.我发现odata请求是...$filter substringof(,Date).因此,我知道使用字符串过滤器"过滤日期是不正确的.

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.

我需要的是...$filter= Date ge datetime'2016-08-17T16:00:00Z' and Date lt datetime'2016-08-18T16:00:00'我可以使用sap.ui.model.Filter吗?还是唯一的方法是由我自己将过滤器参数放在一起?

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?

推荐答案

是的,请使用sap.ui.model.Fitler作为(使用运算符

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)

日期的选择可以通过处理sap.m.DateRangeSelection事件更改"来完成

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

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

这篇关于如何使用sap.ui.model.Filter过滤DateTime数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆