我在我的MVC5网络应用程序中使用DHTMLXScheduler来添加患者并获得患者的预约并在日历中显示,但是我遇到了麻烦,我从数据库获取数据但是这些记录没有根据start_time和end_time添加。
日历控制器:
public ActionResult Index()
{
var sched = new DHXScheduler(this);
sched.Skin = DHXScheduler.Skins.Terrace;
sched.LoadData = true;
sched.EnableDataprocessor = true;
sched.InitialDate = new DateTime(2016, 5, 5);
sched.Config.xml_date = "%d-%M-%Y %g:%i:%s%A";
return View(sched);
}
public ContentResult Data()
{
return (new SchedulerAjaxData(
new Entities().AppointmentsLogs.Select(e=> new { id = e.AppointmentId, start_date = e.StartTime.ToString(), end_date=e.EndTime, text = e.PatientName })
// .Select(e => new { e.id, e.text, e.start_date, e.end_date })
)
);
}
Index.cshtml:
<!DOCTYPE html>
<html>
<head>
<title>DHXScheduler initialization sample</title>
<style>
body {
background-color: #eee;
}
</style>
</head>
<body>
<div name="timeline_tab" style="height:700px;width:900px;margin:0 auto">
@Html.Raw(Model.Render())
</div>
</body>
</html>
<script src="~/scripts/dhtmlxScheduler/dhtmlxscheduler.js"></script>
<script src="~/scripts/dhtmlxScheduler/ext/dhtmlxscheduler_timeline.js"></script>
答案 0 :(得分:2)
看起来您以不同的格式发送开始日期和结束日期:
,start_date = e.StartTime.ToString(),end_date = e.EndTime,
使用系统区域https://msdn.microsoft.com/en-us/library/k494fzbf(v=vs.110).aspx将StartTime转换为字符串,而EndTime作为DateTime传递并由调度程序助手序列化。
如果将两个日期作为DateTime传递,是否会发生任何变化?
new Entities()
.AppointmentsLogs
.Select(e=> new
{
id = e.AppointmentId,
start_date = e.StartTime,
end_date=e.EndTime,
text = e.PatientName
});