【问题标题】:How to customize Syncfusion React Scheduler component?如何自定义 Syncfusion React Scheduler 组件?
【发布时间】:2020-12-08 03:25:26
【问题描述】:

我在我的 React 应用程序中使用 @syncfusion/ej2-react-schedule 组件。我一直在尝试修改默认 UI,但没有任何效果。 Google 上没有关于它的帖子,他们的文档让我感到困惑。

我的问题是:如何修改组件的默认外观?比如更改背景颜色或添加悬停效果...

import { ScheduleComponent, HeaderRowDirective, HeaderRowsDirective, TimelineMonth, Inject, ViewsDirective, ViewDirective, DragAndDrop, Resize } from '@syncfusion/ej2-react-schedule';
import './Timeline.css';

export default function Timeline() {
    return (
        <div className='timeline'>
            <ScheduleComponent width='100%' height='100%' allowDragAndDrop={true}>
                <HeaderRowsDirective>
                    <HeaderRowDirective option='Month'/>
                    <HeaderRowDirective option='Date'/>
                </HeaderRowsDirective>
                <ViewsDirective>
                    <ViewDirective option='TimelineMonth' interval={12}/>
                </ViewsDirective>
                <Inject services={[TimelineMonth, Resize, DragAndDrop]}/>
            </ScheduleComponent>
        </div>
    );
}

我试过类名。我也尝试检查元素并获取它们的名称,然后在 css 文件中也使用它们的名称,但没有任何效果

【问题讨论】:

    标签: css reactjs scheduler syncfusion ej2-syncfusion


    【解决方案1】:

    来自 Syncfusion 支持的问候。

    我们已经验证了您的要求,并在此基础上使用以下 CSS 和代码 sn-ps 准备了一个示例。

    CSS:

    .e-schedule .e-schedule-toolbar .e-toolbar-items.e-tbar-pos,
    .e-schedule .e-timeline-month-view .e-header-month-cell,
    .e-schedule .e-timeline-month-view .e-header-week-cell,
    .e-schedule .e-timeline-month-view .e-header-cells,
    .e-schedule .e-timeline-month-view .e-work-cells  {
        background-color: #ffd9df !important;
    }
    
    .e-schedule .e-toolbar .e-toolbar-items .e-toolbar-item .e-tbar-btn.e-btn,
    .e-schedule .e-timeline-month-view .e-work-cells.custom {
        background-color: pink !important;
    }
    

    Index.js:

    onHover(args) {
      if (args.element.classList.contains('e-work-cells')) {
        let workCells = document.querySelectorAll(".e-work-cells");
        [].forEach.call(workCells, function (ele) {
          ele.classList.remove("custom");
        });
        args.element.classList.add('custom');
      }
    }
    

    示例:https://stackblitz.com/edit/react-header-rows-material-theme-1rcxrc?file=index.js

    并且还让您知道,我们可以使用主题更改调度程序 UI。我们准备了面料和高对比度主题的样品供您参考,可从以下链接查看。

    面料主题:https://stackblitz.com/edit/react-header-rows-fabric-theme-ygtrxs?file=index.html 高对比度主题:https://stackblitz.com/edit/react-header-rows-highcontrast-theme?file=index.html UG:https://ej2.syncfusion.com/react/documentation/appearance/theme/#theming

    请参考以上链接,如果您需要进一步的帮助,请告诉我们。

    【讨论】:

    • 感谢您的支持。这正是我正在努力解决的问题。
    • 其实我还有 1 个问题。如何更改 e.schedule-toolbar 下的“框阴影边框底部”的东西? (使用 CSS)
    • 另外,如何更改 schdule 组件周围的 1px 边框?
    • 我们可以通过使用下面的代码 sn-p 来改变 CSS 值。请根据您的要求更改它。 .e-schedule { border: 0px solid rgba(0, 0, 0, 0.12) !important; } .e-schedule .e-schedule-toolbar { border-bottom: 0 !important; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15) !important; } 示例:[stackblitz.com/edit/… UG:[ej2.syncfusion.com/react/documentation/schedule/getting-started/… 如果您需要进一步的帮助,请告诉我们。
    猜你喜欢
    • 2021-04-01
    • 2021-11-29
    • 2021-12-29
    • 2017-04-05
    • 2022-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多