gpt4 book ai didi

javascript - Kendo Scheduler 任务颜色

转载 作者:行者123 更新时间:2023-11-28 10:33:38 25 4
gpt4 key购买 nike

我想对 ViewModel 中的特定属性的不同值使用不同的颜色。

我的 ViewModel 如下:

public class SchedulerViewModel : ISchedulerEvent
{
public string ScheduleID { get; set; }
public int? RecurrenceID { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
public string RecurrenceRule { get; set; }
public string RecurrenceException { get; set; }
public bool IsAllDay { get; set; }
public string StartTimezone { get; set; }
public string EndTimezone { get; set; }
public int IsDismissed { get; set; }

}

在 View 上,我使用了以下内容::

@(Html.Kendo().Scheduler<Invoice.Models.ViewModels.SchedulerViewModel>()
.Name("scheduler")
.StartTime(DateTime.UtcNow)
.AutoBind(true)
.Date(DateTime.UtcNow)
.Views(views =>
{
views.DayView(dateformat => dateformat.SelectedDateFormat("{0:dd-MMM-yyyy}"));
views.WeekView(weekview => weekview.Selected(true));
views.MonthView();
views.AgendaView();
})

.Resources(resource =>
{
resource.Add(m => m.IsDismissed)
.Title("Is Dismissed")
.DataValueField("Value")
.DataColorField("Color")
.BindTo(new[] {
new { Value = 1, Color = "#f8a398" } , //red
new {Value = 0, Color = "#51a0ed" } //Blue
});
})

.DataSource(d => d
.Batch(false)
.Model(m =>
{
m.Id(f => f.ScheduleID);
m.Field(f => f.Title).DefaultValue("No title");
m.Field(f => f.IsDismissed).DefaultValue(0);
m.Field(f => f.Start).DefaultValue(DateTime.UtcNow);
m.Field(f => f.End).DefaultValue(DateTime.UtcNow);
})
.ServerOperation(true)
.Read("Calendar_ReadSchedule", "Dispatch")
.Create("Calendar_CreateSchedule", "Dispatch")
.Destroy("Calendar_DestroySchedule", "Dispatch")
.Update("Calendar_UpdateSchedule", "Dispatch")

)
)

问题是我在 Scheduler 中只获得了默认的红色任务颜色。但我想要根据属性“IsDismissed”中的值使用不同的颜色。

这怎么可能?

最佳答案

尝试这样的事情:

$(function() {
scheduler_update();
});


function scheduler_update()
{
var calendarResources = [ { "text": "Calendar ONE", "value": "mycalendar1", "color": "#9fc6e7" },{ "text": "Calendar TWO", "value": "mycalendar2", "color": "#7bd148" }];

var calendarFilters = {logic: "or", filters: [ { "field": "value", "operator": "eq", "value": "mycalendar1" },{ "field": "value", "operator": "eq", "value": "mycalendar2" }]};

schedulerTasks = [{"Id": "task1","Title": "Task 1","Description": null,"CalendarId": "mycalendar1","StartDate": "2014-03-19 08:00","EndDate": "2014-03-19 09:00","IsAllDay": false},
{"Id": "task2","Title": "Task 2","Description": null,"CalendarId": "mycalendar2","StartDate": "2014-03-19 10:00","EndDate": "2014-03-19 11:00","IsAllDay": false}];
var schedulerControl = $("#scheduler").data("kendoScheduler");
schedulerControl.resources[0].dataSource.data(calendarResources);
schedulerControl.resources[0].dataSource.filter(calendarFilters);
schedulerDataSource.read();
schedulerControl.view(schedulerControl.view().name);
}

Demo

关于javascript - Kendo Scheduler 任务颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23427267/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com