如何从数据库中获取记录并在 DHTMLXScheduler 日历中显示为事件
How to fetch records from database and display as an event in DHTMLXScheduler Calendar
我在我的 MVC5 web 应用程序中使用 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>
您似乎以不同的格式发送了开始日期和结束日期:
, start_date = e.StartTime.ToString(), end_date=e.EndTime,
StartTime 使用系统文化 https://msdn.microsoft.com/en-us/library/k494fzbf(v=vs.110).aspx 转换为字符串,而 EndTime 作为 DateTime 传递并由调度程序助手序列化。
如果将两个日期都作为 DateTime 传递,会有什么变化吗?
new Entities()
.AppointmentsLogs
.Select(e=> new
{
id = e.AppointmentId,
start_date = e.StartTime,
end_date=e.EndTime,
text = e.PatientName
});
我在我的 MVC5 web 应用程序中使用 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>
您似乎以不同的格式发送了开始日期和结束日期:
, start_date = e.StartTime.ToString(), end_date=e.EndTime,
StartTime 使用系统文化 https://msdn.microsoft.com/en-us/library/k494fzbf(v=vs.110).aspx 转换为字符串,而 EndTime 作为 DateTime 传递并由调度程序助手序列化。
如果将两个日期都作为 DateTime 传递,会有什么变化吗?
new Entities()
.AppointmentsLogs
.Select(e=> new
{
id = e.AppointmentId,
start_date = e.StartTime,
end_date=e.EndTime,
text = e.PatientName
});