【发布时间】:2016-10-26 13:11:45
【问题描述】:
我有一个使用 javascript 生成的剑道网格。我没有数据源,因为数据在页面上,然后 javascript 在其上生成网格。我正在尝试将一列设置为日期类型,但是当我这样做时,该列只是显示为空。
这是生成剑道网格的脚本
var grid = $("#punches").kendoGrid({
dataSource: {
pageSize: 15,
schema: {
model: {
fields: {
PunchDay: { type: 'date' }
}
}
}
},
sortable: true,
selectable: "multiple",
pageable: true,
filterable: true,
scrollable: false,
groupable: true,
resizable: true
}).data("kendoGrid");
当我设置类型时,PunchDay 列显示为空。我相信这与该列中设置的数据有关
@FieldTranslation.ToShortDate(Html.DisplayFor(modelItem => item.PunchDay).ToString())
因为它是字符串而不是日期格式。但是,我没有办法解决这个问题。我的网格代码是
<table class="table" id="punches">
<thead>
<tr>
<th title="@FieldTranslation.GetLabel("ID", GlobalVariables.LanguageID)">
@FieldTranslation.GetLabel("ID", GlobalVariables.LanguageID)
</th>
<th title="@FieldTranslation.GetLabel("EmployeeName", GlobalVariables.LanguageID)">
@FieldTranslation.GetLabel("EmployeeName", GlobalVariables.LanguageID)
</th>
<th title="@FieldTranslation.GetLabel("PunchDay", GlobalVariables.LanguageID)">
@FieldTranslation.GetLabel("PunchDay", GlobalVariables.LanguageID)
</th>
<th title="@FieldTranslation.GetLabel("PunchIn", GlobalVariables.LanguageID)">
@FieldTranslation.GetLabel("PunchIn", GlobalVariables.LanguageID)
</th>
<th title="@FieldTranslation.GetLabel("PunchOut", GlobalVariables.LanguageID)">
@FieldTranslation.GetLabel("PunchOut", GlobalVariables.LanguageID)
</th>
<th title="@FieldTranslation.GetLabel("Adjustment Time", GlobalVariables.LanguageID)">
@FieldTranslation.GetLabel("Adjustment Time", GlobalVariables.LanguageID)
</th>
<th title="@FieldTranslation.GetLabel("Adjustment Description", GlobalVariables.LanguageID)">
@FieldTranslation.GetLabel("Adjustment Description", GlobalVariables.LanguageID)
</th>
<th title="@FieldTranslation.GetLabel("WorkHours", GlobalVariables.LanguageID)">
@FieldTranslation.GetLabel("WorkHours", GlobalVariables.LanguageID)
</th>
@*<th>
@Html.DisplayNameFor(model => model.Inactive)
</th>*@
<th title="@FieldTranslation.GetLabel("Department", GlobalVariables.LanguageID)">
@FieldTranslation.GetLabel("Department", GlobalVariables.LanguageID)
</th>
<th width="125px;" class="hidden-filter">Actions</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.ID)
</td>
<td>
@Html.DisplayFor(modelItem => item.EmployeeName)
</td>
<td>
@FieldTranslation.ToShortDate(Html.DisplayFor(modelItem => item.PunchDay).ToString())
</td>
<td>
@FieldTranslation.ToShortTime(Html.DisplayFor(modelItem => item.PunchIn).ToString())
</td>
<td>
@FieldTranslation.ToShortTime(Html.DisplayFor(modelItem => item.PunchOut).ToString())
</td>
<td>
@Html.DisplayFor(modelItem => item.AdjustTime)
</td>
<td>
@Html.DisplayFor(modelItem => item.AdjustDescr)
</td>
<td>
@Html.DisplayFor(modelItem => item.WorkHours)
</td>
@*<td>
@Html.DisplayFor(modelItem => item.Inactive)
</td>*@
<td>
@Html.DisplayFor(modelItem => item.Department)
</td>
<td>
<a href="@Url.Action("EditTime", "TimePunches", new {id = item.ID, flt = ViewBag.FLT})" title="Edit"><i class="icon-edit fa fa-pencil fa-fw fa-lg"></i></a>
<a href="@Url.Action("PunchLogIndex", "TimePunches", new {id = item.ID, flt = ViewBag.FLT})" title="Punch Log"><i class="icon-purple fa fa-book fa-fw fa-lg"></i></a>
<a href="@Url.Action("PunchRequestIndex", "TimePunches", new { punchId = item.ID, flt = ViewBag.FLT })" title="See Change Request Log"><i class="icon-niagara fa fa-list fa-fw fa-lg"></i></a>
<a href="#" id="delete" data-id="@item.ID" data-client="@item.ClientID"><i class="icon-red fa fa-times fa-fw fa-lg"></i></a>
</td>
</tr>
}
</tbody>
</table>
我该怎么做才能让我的约会对象重新出现?
【问题讨论】:
-
您是否尝试将其保留为字符串并添加列部分?
-
我确实尝试过@soham,它似乎只是打破了网格。不过滤或做任何事情。
标签: javascript jquery asp.net-mvc kendo-grid