【问题标题】:MVC kendogrid not showing datetime string valueMVC kendogrid 不显示日期时间字符串值
【发布时间】:2017-01-17 12:29:06
【问题描述】:

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

控制器sn-p:

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 })) 
      )

【问题讨论】:

  • Refer here 和该页面上的链接 - 注意&lt;a&gt;&lt;/a&gt; 标签之间没有文字
  • 啊..谢谢。通过在标签之间输入 ReviewDate 完美工作

标签: asp.net-mvc kendo-grid


【解决方案1】:

尝试更改您的客户端模板

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-11
    相关资源
    最近更新 更多