您好我有一个 mDataPropDateTime
格式问题。基本上我想在一列中显示日期,在另一列中显示时间。
但据我了解,mDataProp 与您的模型直接相关,它没有时间属性,只是一个日期......
控制器
var result = from a in data
select new
{
appointmentDate = a.AppointmentDate.ToShortDateString(),//.ToString("g"),
appointmentTime = a.AppointmentDate.ToLocalTime().ToString("t"),
appointmentName = a.AppointmentType.AppName,
appointmentID = a.AppointmentID
};
//Return Json data for Datatable
return Json(new
{
sEcho = param.sEcho,
iTotalRecords = total,
iTotalDisplayRecords = total,
aaData = result
});
看法
<script>
$(document).ready(function () {
var urlRequest = $('#apptTable').data("request-url");
var detailRequest = $('#apptTable').data("detail-url");
$('#apptTable').dataTable({
"bSort": false,
"bServerSide": true,
"sAjaxSource": urlRequest,
"sServerMethod": "POST",
"bProcessing": true,
"bFilter": false,
"aoColumns": [
{ "mDataProp": "appointmentDate" },
{ "mDataProp": "appointmentDate" },
{ "mDataProp": "appointmentName" },
{
"mDataProp": "appointmentID",
"fnRender": function (oObj) {
return '<a href=\"' + detailRequest + '/' + oObj.aData.appointmentID + '\">Details</a>';
}
}
]
});
});
</script>
我无法创建appointmentDate
在控制器中调用的第二个变量,因此我必须在视图中进行格式化。
有任何想法吗?