2017-09-11 95 views
0

我在我的MVC5 web应用程序中使用DHTMLXScheduler来添加患者并获取患者的预约并在日历中显示此信息,但我遇到了麻烦,根据start_time和end_time没有添加记录。如何从数据库中获取记录并将其显示为DHTMLXScheduler中的事件日历

日历控制器:

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> 

回答

2

看起来你以不同的格式发送的开始和结束日期:

,START_DATE = e.StartTime.ToString(),end_date = e.EndT IME,

开始时间是使用系统培养https://msdn.microsoft.com/en-us/library/k494fzbf(v=vs.110).aspx转换成字符串,而结束时间作为日期时间传递和由调度辅助序列化。

如果您将两个日期都作为DateTime传递,是否有任何更改?

new Entities() 
    .AppointmentsLogs 
    .Select(e=> new 
    { 
     id = e.AppointmentId, 
     start_date = e.StartTime, 
     end_date=e.EndTime, 
     text = e.PatientName 
    }); 
相关问题