我有一个 Telerik Grid,其中一列具有日期时间值,但该字段上的过滤器不起作用,因为默认情况下过滤器只接受日期。有什么方法可以将时间包含在 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"))
%>
我知道这是一篇旧帖子,但我会为那些搜索它的人提供解决方案
我已经定制了这个解决方案,它适用于所有场景,如果你有多个列,你也可以使用它有一个日期时间过滤器在需要数据源事件中使用这个函数首先把这个函数放在你的代码中
然后你像这样从网格的需要数据源事件中调用它
对于多日期列,您可以像这样使用它
请享用 :)