简体   繁体   English

WPF DevExpress网格日期过滤字符串

[英]WPF DevExpress Grid date filterstring

I'm trying to apply filter parameters from a little form to a DevExpress grid. 我正在尝试将过滤器参数从某种形式应用于DevExpress网格。 I did this by binding the FilterString from the grid to a string in the ViewModel. 我是通过将FilterString从网格绑定到ViewModel中的字符串来实现的。

​currently I construct the filterstring as follows: ​ 当前我按如下方式构造过滤器字符串:

filterString += "[" + column.Header + "] >= '" 
                + ((DateTime)searchParameter).ToString("dd-MM-yyyy") 
                + "' AND [" + column.Header + "] < '" 
                + ((DateTime)searchParameter).AddDays(1).ToString("dd-MM-yyyy") 
                + "'";

in which the column header and field name come from the columnMap and the searchParameter is the date to filter on. 其中列标题和字段名称来自columnMap,而searchParameter是要进行过滤的日期。

The filter is applied correctly and also shown in the bottom of the grid. 过滤器已正确应用,并显示在网格底部。 You can also edit it, but only string values are shown in the filter row at the top of the grid. 您也可以对其进行编辑,但是在网格顶部的过滤器行中仅显示字符串值。 Dates or Numbers aren't shown there. 日期或数字未显示在此处。

How can I also get dates and numbers to show in the filter row if I set a filterstring? 如果设置了过滤器字符串,如何获取日期和数字以显示在过滤器行中?

It currently looks like this when filtering on name (data edited out): 当前在过滤名称(数据已删除)时如下所示: 在此处输入图片说明

This should help you: 这应该可以帮助您:

GridColumn.FilterMode Property GridColumn.FilterMode属性

DX suggests to set GridColumn.FilterMode property of the date column to DisplayText . DX 建议将日期列的GridColumn.FilterMode属性设置为DisplayText

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM