在视图页面 ViewModel.cshtml 中的网格的其中一列中, 我使用“ .sortable ”对列进行排序。但是,该列是日期,我的行按日期的日期和月份排序,但不是年份。如何按整个日期对行进行排序,包括日,月和年。
@(Html.Kendo().Grid<viewmodel>()
.Name("SomeName")
.Sortable(x => x.Enabled(true))
.HtmlAttributes(new {style = "border: 1px solid black;"})
.DataSource(ds => ds
.Ajax()
.ServerOperation(false)
.Read(read => read.Action("someAction", "SomeController"))
)
.Events(e => e.DataBound("SomeDatabound"))
.Columns(c =>
{
c.Bound(m => m.Title1).Title("Title1").Width(300).Sortable(true);
c.Bound(m => m.CreatedDate).Title("CreatedDate").Sortable(true);
})
.Resizable(resize => resize.Columns(true)))
答案 0 :(得分:1)
如果您按照these步骤操作并按如下方式设置列格式:
columns.Bound(m => m.CreatedDate).Format("{0:yyyy.MM.dd.}").Title("CreatedDate").Sortable(true);
它应该正确排序您的列。
(yyyy.MM.dd.
只是一个例子)