Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 如何在DHTMLX控件事件调度程序中设置文本颜色和背景_Asp.net Mvc_Dhtmlx_Dhtmlx Scheduler - Fatal编程技术网

Asp.net mvc 如何在DHTMLX控件事件调度程序中设置文本颜色和背景

Asp.net mvc 如何在DHTMLX控件事件调度程序中设置文本颜色和背景,asp.net-mvc,dhtmlx,dhtmlx-scheduler,Asp.net Mvc,Dhtmlx,Dhtmlx Scheduler,我想在DHTMLX控件事件调度程序的文本/背景上显示不同的颜色。下面是我的代码,我只传递虚拟数据- public ActionResult Index() { var scheduler = new DHXScheduler(this); scheduler.Skin = DHXScheduler.Skins.Flat; scheduler.Config.multi_day = true;

我想在DHTMLX控件事件调度程序的文本/背景上显示不同的颜色。下面是我的代码,我只传递虚拟数据-

 public ActionResult Index()
        {
            var scheduler = new DHXScheduler(this);
            scheduler.Skin = DHXScheduler.Skins.Flat;
            scheduler.Config.multi_day = true;
            scheduler.InitialDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
            scheduler.LoadData = true;
            scheduler.EnableDataprocessor = true;
            return View(scheduler);
        }


  public ContentResult Data()
        {
            var data = new SchedulerAjaxData(
                new List<CalendarEvent>{
                    new CalendarEvent{
                        id = 1,
                        text = "Sample Event",
                        start_date = new DateTime(2017, 04, 09, 3, 00, 00),
                        end_date = new DateTime(2017, 04, 09, 4, 00, 00)

                    },
                    new CalendarEvent{
                        id = 2,
                        text = "Event Anniversery",
                         start_date = new DateTime(2017, 04, 08, 6, 00, 00),
                        end_date = new DateTime(2017, 04, 08, 8, 00, 00)
                    },
                    new CalendarEvent{
                        id = 3,
                        text = "Third Event",
                         start_date = new DateTime(2017, 04, 07, 8, 00, 00),
                        end_date = new DateTime(2017, 04, 07, 9, 00, 00)
                    }
                }
            );
            return (ContentResult)data;
        }
public ActionResult Index()
{
var调度程序=新的DHXScheduler(此);
scheduler.Skin=DHXScheduler.Skins.Flat;
scheduler.Config.multi_day=true;
scheduler.InitialDate=new DateTime(DateTime.Now.Year,DateTime.Now.Month,DateTime.Now.Day);
scheduler.LoadData=true;
scheduler.EnableDataprocessor=true;
返回视图(调度程序);
}
公共内容结果数据()
{
var数据=新的SchedulerAjaxData(
新名单{
新日历事件{
id=1,
text=“示例事件”,
开始日期=新的日期时间(2017,04,09,3,00,00),
结束日期=新的日期时间(2017,04,09,4,00,00)
},
新日历事件{
id=2,
text=“事件周年纪念”,
开始日期=新的日期时间(2017,04,08,6,00,00),
结束日期=新的日期时间(2017、04、08、8、00、00)
},
新日历事件{
id=3,
text=“第三事件”,
开始日期=新的日期时间(2017,04,07,8,00,00),
结束日期=新日期时间(2017,04,07,9,00,00)
}
}
);
返回(ContentResult)数据;
}

请帮帮我。我在谷歌上没有找到任何结果。

你看过这篇文章了吗

简而言之,您可以在事件对象的属性中存储颜色:

public class Event
{
    public int id { get; set; }
    public string text { get; set; }
    public DateTime? start_date { get; set; }
    public DateTime? end_date { get; set; }
    public string color { get; set; }
    public string textColor { get; set; }
}
数据:

或者,您可以基于其他属性将css类附加到事件元素:

Javascript:

scheduler.templates.event_class = function(start, end, event){
    if(event.someProperty){
        return "colored-event";
    }
    return "";
};
CSS:

scheduler.templates.event_class = function(start, end, event){
    if(event.someProperty){
        return "colored-event";
    }
    return "";
};
/*event in day or week view*/
.dhx_cal_event.colored-event div{
    background-color: #FF0000 !important;
    color: #FFFFFF !important;
}

/*multi-day event in month view*/
.dhx_cal_event_line.colored-event{
    background-color: #FF0000 !important;
    color: #FFFFFF !important;
}

/*single-day event in month view*/
.dhx_cal_event_clear.colored-event{
    color: #FF0000 !important;
}