0

我使用 dhtmlx 计划和问题将数据加载到计划程序视图中。我首先使用数据库,所以我有一个 sp 来获取所有详细信息以显示在调度程序上,

public ContentResult Data()
        {
            var data = new SchedulerAjaxData(
                new Entities().tblAppTime.Select(e => new { e.SharedId, e.StartTime, e.Duration}));
           return data;}

var data 的输出(在调试期间):

   {[{"SharedId":54,"StartTime":"09/14/2013 10:00","Duration":"09/14/2013 11:20"},{"SharedId":56,"StartTime":"09/14/2013 10:00","Duration":"09/14/2013 10:40"},
    {[{"SharedId":10,"StartTime":"09/12/2013 8:50","Duration":"09/12/2013 8:55"},{"SharedId":56,"StartTime":"09/14/2013 10:00","Duration":"09/14/2013 10:40"}]}

我仍然没有在调度程序中绑定这个,请帮助。

更新:

controller.cs
 sched.BeforeInit.Add("customeventbox()");


public ContentResult Data()
        {
         var scheduler = new DHXScheduler();
          scheduler.InitialDate=  DateTime.Today ;
            var data = new SchedulerAjaxData(new OnlineABEntities().GetAppointmentsDisplay(scheduler.InitialDate).Select(e => new {id= e.ID, e.ResourceID,start_date= e.StartTime,end_date= e.Duration, e.Color,text=""}));
            return data;
        }

schedscript.js

function customeventbox() {

    debugger;
    scheduler.attachEvent("onTemplatesReady", function () {
        alert("eventbox");
        scheduler.templates.event_header = function (start, end, ev) {
            alert("eventbox1");
                       return scheduler.templates.event_date(ev.StartTime) + "-" +
                       scheduler.templates.event_date(ev.Duration);
                   };
                   scheduler.templates.event_text = function (start, end, event) {
                       alert("eventboxtext");
                       debugger;
                       return "<br>" + event.ID + "<br>"+event.Duration +"<br>"+event.StartTime+"<br>"+event.Color+ "sampleready" + "<br>"+ "sampletext" ;
          }
         });
    }
4

1 回答 1

3

调度器对加载的数据有一些要求, 查看文档中的文章。简而言之,输出数据必须至少包含以下四个属性,全部区分大小写 - idstart_dateend_datetext

如果您像这样获取数据,它将显示在调度程序中

var data = new SchedulerAjaxData(
    new Entities().tblAppTime.Select(e => new { id = e.SharedId, start_date = e.StartTime, end_date = e.Duration, text = ""})
);

更新

客户端上的数据对象将具有与已传递给 SchedulerAjaxData 的对象相同的属性集。事件的开始和结束日期是 JS 日期对象,所以在输出之前应该将它们转换为字符串。

scheduler.templates.event_text = function (start, end, event) {

    var dateToStr = scheduler.date.date_to_str("%H:%i");

    return "<br>" + event.id + 
        "<br>" + dateToStr(event.end_date) +
        "<br>" + dateToStr(event.start_date) +
        "<br>" + event.Color + 
        "sampleready" + "<br>"+ "sampletext" ;
}

这是有关日期格式掩码的详细信息 http://docs.dhtmlx.com/scheduler/settings_format.html

于 2013-09-16T07:38:57.113 回答