2016-07-12 52 views
0

我在具有数据类型TimeSpan(ASP.NET)的kendo Grid中有一列。我有两个问题:kendo UI Grid Grid Timespan过滤

  1. 首先,它不格式化,格式为HH时间:毫米
  2. 其次,当我筛选我的错误 - 从字符串转换为时间跨度失败。

带钢下来版本的代码看起来像

@(Html.Kendo().Grid<SomeModel>() 
.Name("Grid") 
.Columns(colums => 
{ 
    columns.Bound(c => c.StartTime).Title("Start Time"); // TimeSpan data type 
}) 

回答

0

1,您应该使用一个客户端模板来显示时间跨度列:

columns.Bound(p => p.StartTime).ClientTemplate("#= StartTime.Minutes #:#= StartTime.Seconds #:#= StartTime.Milliseconds #"); 

了解更多详情请参考:http://www.telerik.com/forums/working-with-timespans

2您应该创建一个自定义函数,如果客户端过滤是作为数据源的过滤器传递的需要http://www.telerik.com/forums/how-to-define-a-custom-filter-operator ,在这里你将还需要一个timepicker或自定义编辑器允许将显示,当用户将按下筛选按钮http://demos.telerik.com/kendo-ui/grid/filter-menu-customization

0

创建像这样的服务器上的计算性能...

public string ComputedTime { 
set{ 
var time = StartTime.ToShortDateString(); 

// extra work here 
return time; 
} 
} 

然后在剃刀

@(Html.Kendo().Grid<SomeModel>() 
.Name("Grid") 
.Columns(colums => 
{ 
    columns.Bound(c => c.ComputedTime).Title("Start Time"); // TimeSpan data type 
})