我正在使用具有嵌套属性的asp.net核心MVC kendo网格列。我具有datetime类型的列“ CreatedDate”,但我只想使用属性中的日期部分,例如“ CreatedDate.Date”。我已经为“ CreatedDate”列应用了filterable选项,它运行良好。
columns.Bound(c => c.CreatedDate).Title("Created On")
.Filterable(x=>x.Operators(d=>d.ForDate(o=>o.Clear()
.IsGreaterThan("Is Greater Than")
.IsLessThan("Is Less Than"))));
但是当我对具有嵌套属性(例如“ CreatedDate.Date”)的同一列应用可过滤选项时,它将无法正常工作。所有过滤器选项均显示在列表中。
columns.Bound(c => c.CreatedDateTimeUtc.Date).Title("Created On")
.Filterable(x=>x.Operators(d=>d.ForDate(o=>o.Clear()
.IsGreaterThan("Is Greater Than")
.IsLessThan("Is Less Than"))));
我是否缺少为嵌套属性添加的任何内容以应用自定义可过滤选项?请帮助我解决此问题
我认为Kendo不会将复杂的对象过滤掉。一种选择是将字段添加到视图模型中,这样就不再复杂了。否则,您可以捕获过滤器事件并在javascript函数中处理该字段的过滤。
此文档可能会有所帮助:
https://demos.telerik.com/aspnet-mvc/grid/events
https://docs.telerik.com/kendo-ui/knowledge-base/grid-filter-column-with-dropdownlist