Telerik 网格过滤器不适用于日期列
我有一个 Telerik 网格,其中一列具有日期时间值,但该字段上的过滤器不起作用,因为默认情况下过滤器仅接受日期。 有什么办法可以将时间包含在 Telerik 网格过滤器中吗?
这是我的代码:
Html.Telerik().Grid()
.Name("FilesGrid")
.Sortable(sorting => sorting.OrderBy(sortOrder => sortOrder.Add(o => o.COL1)))
.Pageable(paging =>
paging.PageSize(10)
.Style(GridPagerStyles.NextPreviousAndNumeric)
.Position(GridPagerPosition.Bottom)
).Filterable()
.Groupable()
.Selectable()
.Resizable(c => c.Columns(true))
.DataBinding(dataBinding => dataBinding.
Ajax()
.Select("_Grid", "Files")
.Update("_ClientUpdate", "Todos")
.Insert("_ClientInsert", "Todos")
.Delete("Delete", "Files"))
.EnableCustomBinding(true)
.Columns(columns =>
{
columns.Bound(c => c.col1);
columns.Bound(c => c.col2);
columns.Bound(c => c.col3);
columns.Bound(c => c.CreatedAt); -------- this column is datetime but filter only has date calendar , hence the filter wont work
.ClientEvents(events => events.OnDataBound("onGridDataBound"))
%>
I have a Telerik Grid with one of the column having Date Time values, but the filter on that field is not working as the filter only accepts date by default.
Is there any way we can have the time included in the telerik grid filter?
Here is my code:
Html.Telerik().Grid()
.Name("FilesGrid")
.Sortable(sorting => sorting.OrderBy(sortOrder => sortOrder.Add(o => o.COL1)))
.Pageable(paging =>
paging.PageSize(10)
.Style(GridPagerStyles.NextPreviousAndNumeric)
.Position(GridPagerPosition.Bottom)
).Filterable()
.Groupable()
.Selectable()
.Resizable(c => c.Columns(true))
.DataBinding(dataBinding => dataBinding.
Ajax()
.Select("_Grid", "Files")
.Update("_ClientUpdate", "Todos")
.Insert("_ClientInsert", "Todos")
.Delete("Delete", "Files"))
.EnableCustomBinding(true)
.Columns(columns =>
{
columns.Bound(c => c.col1);
columns.Bound(c => c.col2);
columns.Bound(c => c.col3);
columns.Bound(c => c.CreatedAt); -------- this column is datetime but filter only has date calendar , hence the filter wont work
.ClientEvents(events => events.OnDataBound("onGridDataBound"))
%>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这是一篇旧帖子,但我会为那些搜索它的人提供一个解决方案
我已经定制了这个解决方案,它适用于所有场景,如果您有多个列有日期时间过滤器,您也可以使用它使用此功能在需要数据源事件中
首先将此函数放入您的代码中
,然后从网格的需要数据源事件中调用它
,对于多日期列,您可以像这样使用它
享受:)
I know it's an old post but I will put a solution for those people search for it
I have customized this solution, it works with all scenarios and you can use it also if you have more than one column have a date time filter use this function in the need data source event
first put this function in your code
and then you call it from the need data source event for the grid like this
and for multi date column you can use it like this
enjoy :)