angular - Angular Syncfusion Scheduler - 将颜色设置为单个事件
问题描述
我正在使用 Angular EJ2 Syncfusion Scheduler,但我无法为每个事件设置单独的颜色,我只能为同一行中的一组事件设置颜色。
示例:在以下调度程序中,我想为David设置蓝色,为Peter设置红色。我只能为一行事件设置相同的颜色,但不能为单个事件设置相同的颜色。
解决方案
事件的背景颜色是根据colorField设置的。如果我们想为每个事件设置单独的颜色,我们应该删除colorField并在事件对象中包含自定义字段以保持颜色。
{
Id: 10,
Name: "David",
StartTime: new Date(2018, 7, 1, 9, 0),
EndTime: new Date(2018, 7, 1, 10, 0),
Description: "Health Checkup",
DepartmentID: 1,
ConsultantID: 1,
DepartmentName: "GENERAL",
CategoryColor: "Blue"
}
并且,通过使用如下所示的eventRendered事件,在事件渲染时应用此颜色字段。
oneventRendered(args: EventRenderedArgs): void {
let categoryColor: string = args.data.CategoryColor as string;
if (!args.element || !categoryColor) {
return;
}
if (this.scheduleObj.currentView === 'Agenda') {
(args.element.firstChild as HTMLElement).style.borderLeftColor = categoryColor;
} else {
args.element.style.backgroundColor = categoryColor;
}
}
如需更多参考,请参阅下面的演示链接,并与我们联系以获得进一步的帮助。
示例:https ://stackblitz.com/edit/angular-udwvvf-fbm7mw?file=app.component.ts
推荐阅读
- rust - 使用 Rust NOM 解析库迭代多行
- react-native - Expo- av:自动播放视频
- jquery - 使用Jquery在多维数组中增加键名
- google-sheets - 使用 ATAN/ATAN2 计算两点之间的角度,其中 x2 - x1 = 0
- javascript - Firebase createUserWithEmailAndPassword 在 Next.js 中没有做任何事情
- java - 我试图通过for循环调用一个方法,第一次迭代只会读取方法中的第一行代码
- python - 使用 googletrans 将 pandas 数据帧从英语翻译成法语的问题
- python - 使用 Keras 训练时的维度问题
- regex - 正则表达式将匹配左括号之前的文本,但不匹配左括号本身
- flutter - 如何使抽屉小部件透明