MVC kendogrid没有显示日期时间字符串值

时间:2017-01-17 04:11:08

标签: asp.net-mvc kendo-grid

我有一个kendo网格,它返回除第一列之外的所有结果,即日期。它显示为空白。在我的viewmodel中,reviewdate的类型为string。在我的控制器中,我将reviewdate转换为字符串。我知道reviewdate从debug返回MM / dd / yyyy。

Controller snippet:

foreach (var item in query)
{
    model.Add(new PreviousReviewViewModel()
    {
        ReviewId = item.ReviewId,
        ReviewDate = item.NextReviewDt.ToString("MM/dd/yyyy"),
        Rating = item.Rating,
        SubmittedFl = item.SubmittedFl
    });

}

在我看来,我的网格如下:

@(Html.Kendo().Grid<PreviousReviewViewModel>()
      .Name("Grid")
      //.HtmlAttributes(new { style = "width:450px;" })
      .Columns(columns =>
      {
          columns.Template(
            @<text>
                @Html.ActionLink(Model.ReviewDate, "SavedFormsIndex", new { Controller = "Forms", id = Model.ReviewId })
            </text>).ClientTemplate(@"<a href=""/Forms/SavedFormsIndex?id=#=ReviewId#""></a>").Title("Review Date");
          columns.Bound(m => m.Rating).Title("Composite Rating"); //rating is the avg
          columns.Bound(m => m.SubmittedFl).Title("Submitted");
      })
      .Pageable(p => p.Numeric(false).PreviousNext(false).Refresh(true))
      .Resizable(resize => resize.Columns(true))
      .Scrollable()
      .DataSource(dataSource => dataSource
          .Ajax()
          .PageSize(2147483647)
          .Read(read => read.Action("read_PrevProjReviews", "Forms", new { id = ViewBag.ProjectId })) 
      )

1 个答案:

答案 0 :(得分:0)

尝试更改您的客户端模板

.ClientTemplate(@"<a href=""/Forms/SavedFormsIndex?id=#=ReviewId#"">#=ReviewDate#</a>