import React, { useCallback, useState } from 'react';
import Scheduler, {
Resource,
Editing,
Form as SchedulerForm,
Item,
type SchedulerTypes,
} from 'devextreme-react/scheduler';
import RadioGroup from 'devextreme-react/radio-group';
import type { RadioGroupTypes } from 'devextreme-react/radio-group';
import {
data, assignees, rooms, priorities, resourcesList,
} from './data.ts';
const currentDate = new Date(2021, 3, 27);
const views: SchedulerTypes.ViewType[] = ['workWeek'];
const App = () => {
const [currentResource, setCurrentResource] = useState(resourcesList[0]);
const onRadioGroupValueChanged = useCallback((e: RadioGroupTypes.ValueChangedEvent) => {
setCurrentResource(e.value);
}, []);
return (
<>
<Scheduler
timeZone="America/Los_Angeles"
dataSource={data}
views={views}
defaultCurrentView="workWeek"
defaultCurrentDate={currentDate}
startDayHour={9}
endDayHour={19}
height={600}
>
<Resource
dataSource={rooms}
fieldExpr="roomId"
label="Room"
useColorAsDefault={currentResource === 'Room'}
icon="conferenceroomoutline"
/>
<Resource
dataSource={priorities}
fieldExpr="priorityId"
label="Priority"
useColorAsDefault={currentResource === 'Priority'}
icon="tags"
/>
<Resource
dataSource={assignees}
allowMultiple={true}
fieldExpr="assigneeId"
label="Assignee"
useColorAsDefault={currentResource === 'Assignee'}
icon="user"
/>
<Editing>
<SchedulerForm>
<Item name="mainGroup">
<Item name="subjectGroup" />
<Item name="dateGroup" />
<Item name="repeatGroup" />
<Item name="resourcesGroup">
<Item name="roomIdGroup" colCount={3} colCountByScreen={{ xs: 3 }}>
<Item name="roomIdIcon" />
<Item name="roomIdEditor" />
<Item name="priorityIdEditor" />
</Item>
<Item name="assigneeIdGroup" />
</Item>
<Item name="descriptionGroup" />
</Item>
<Item name="recurrenceGroup" />
</SchedulerForm>
</Editing>
</Scheduler>
<div className="options">
<div className="caption">Use colors of:</div>
<div className="option">
<RadioGroup
items={resourcesList}
value={currentResource}
layout="horizontal"
onValueChanged={onRadioGroupValueChanged}
/>
</div>
</div>
</>
);
};
export default App;
import React, { useCallback, useState } from 'react';
import Scheduler, {
Resource,
Editing,
Form as SchedulerForm,
Item,
} from 'devextreme-react/scheduler';
import RadioGroup from 'devextreme-react/radio-group';
import {
data, assignees, rooms, priorities, resourcesList,
} from './data.js';
const currentDate = new Date(2021, 3, 27);
const views = ['workWeek'];
const App = () => {
const [currentResource, setCurrentResource] = useState(resourcesList[0]);
const onRadioGroupValueChanged = useCallback((e) => {
setCurrentResource(e.value);
}, []);
return (
<>
<Scheduler
timeZone="America/Los_Angeles"
dataSource={data}
views={views}
defaultCurrentView="workWeek"
defaultCurrentDate={currentDate}
startDayHour={9}
endDayHour={19}
height={600}
>
<Resource
dataSource={rooms}
fieldExpr="roomId"
label="Room"
useColorAsDefault={currentResource === 'Room'}
icon="conferenceroomoutline"
/>
<Resource
dataSource={priorities}
fieldExpr="priorityId"
label="Priority"
useColorAsDefault={currentResource === 'Priority'}
icon="tags"
/>
<Resource
dataSource={assignees}
allowMultiple={true}
fieldExpr="assigneeId"
label="Assignee"
useColorAsDefault={currentResource === 'Assignee'}
icon="user"
/>
<Editing>
<SchedulerForm>
<Item name="mainGroup">
<Item name="subjectGroup" />
<Item name="dateGroup" />
<Item name="repeatGroup" />
<Item name="resourcesGroup">
<Item
name="roomIdGroup"
colCount={3}
colCountByScreen={{ xs: 3 }}
>
<Item name="roomIdIcon" />
<Item name="roomIdEditor" />
<Item name="priorityIdEditor" />
</Item>
<Item name="assigneeIdGroup" />
</Item>
<Item name="descriptionGroup" />
</Item>
<Item name="recurrenceGroup" />
</SchedulerForm>
</Editing>
</Scheduler>
<div className="options">
<div className="caption">Use colors of:</div>
<div className="option">
<RadioGroup
items={resourcesList}
value={currentResource}
layout="horizontal"
onValueChanged={onRadioGroupValueChanged}
/>
</div>
</div>
</>
);
};
export default App;
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App.tsx';
ReactDOM.render(
<App />,
document.getElementById('app'),
);
import type { SchedulerTypes } from 'devextreme-react/scheduler';
type Appointment = SchedulerTypes.Appointment & { priorityId: number, roomId: number, assigneeId: number[] };
export const resourcesList = ['Assignee', 'Room', 'Priority'];
export const data: Appointment[] = [
{
text: 'Website Re-Design Plan',
assigneeId: [4],
roomId: 1,
priorityId: 2,
startDate: new Date('2021-04-26T16:30:00.000Z'),
endDate: new Date('2021-04-26T18:30:00.000Z'),
}, {
text: 'Book Flights to San Fran for Sales Trip',
assigneeId: [2],
roomId: 2,
priorityId: 1,
startDate: new Date('2021-04-26T19:00:00.000Z'),
endDate: new Date('2021-04-26T20:00:00.000Z'),
allDay: true,
}, {
text: 'Install New Router in Dev Room',
assigneeId: [1],
roomId: 1,
priorityId: 2,
startDate: new Date('2021-04-26T21:30:00.000Z'),
endDate: new Date('2021-04-26T22:30:00.000Z'),
}, {
text: 'Approve Personal Computer Upgrade Plan',
assigneeId: [3],
roomId: 2,
priorityId: 2,
startDate: new Date('2021-04-27T17:00:00.000Z'),
endDate: new Date('2021-04-27T18:00:00.000Z'),
}, {
text: 'Final Budget Review',
assigneeId: [1],
roomId: 1,
priorityId: 1,
startDate: new Date('2021-04-27T19:00:00.000Z'),
endDate: new Date('2021-04-27T20:35:00.000Z'),
}, {
text: 'New Brochures',
assigneeId: [4],
roomId: 3,
priorityId: 2,
startDate: new Date('2021-04-27T21:30:00.000Z'),
endDate: new Date('2021-04-27T22:45:00.000Z'),
}, {
text: 'Install New Database',
assigneeId: [2],
roomId: 3,
priorityId: 1,
startDate: new Date('2021-04-28T16:45:00.000Z'),
endDate: new Date('2021-04-28T18:15:00.000Z'),
}, {
text: 'Approve New Online Marketing Strategy',
assigneeId: [4],
roomId: 2,
priorityId: 1,
startDate: new Date('2021-04-28T19:00:00.000Z'),
endDate: new Date('2021-04-28T21:00:00.000Z'),
}, {
text: 'Upgrade Personal Computers',
assigneeId: [2],
roomId: 2,
priorityId: 2,
startDate: new Date('2021-04-28T22:15:00.000Z'),
endDate: new Date('2021-04-28T23:30:00.000Z'),
}, {
text: 'Customer Workshop',
assigneeId: [3],
roomId: 3,
priorityId: 1,
startDate: new Date('2021-04-29T18:00:00.000Z'),
endDate: new Date('2021-04-29T19:00:00.000Z'),
allDay: true,
}, {
text: 'Prepare 2021 Marketing Plan',
assigneeId: [1],
roomId: 1,
priorityId: 2,
startDate: new Date('2021-04-29T18:00:00.000Z'),
endDate: new Date('2021-04-29T20:30:00.000Z'),
}, {
text: 'Brochure Design Review',
assigneeId: [4],
roomId: 1,
priorityId: 1,
startDate: new Date('2021-04-29T21:00:00.000Z'),
endDate: new Date('2021-04-29T22:30:00.000Z'),
}, {
text: 'Create Icons for Website',
assigneeId: [3],
roomId: 3,
priorityId: 1,
startDate: new Date('2021-04-30T17:00:00.000Z'),
endDate: new Date('2021-04-30T18:30:00.000Z'),
}, {
text: 'Upgrade Server Hardware',
assigneeId: [4],
roomId: 2,
priorityId: 2,
startDate: new Date('2021-04-30T21:30:00.000Z'),
endDate: new Date('2021-04-30T23:00:00.000Z'),
}, {
text: 'Submit New Website Design',
assigneeId: [1],
roomId: 1,
priorityId: 2,
startDate: new Date('2021-04-30T23:30:00.000Z'),
endDate: new Date('2021-05-01T01:00:00.000Z'),
}, {
text: 'Launch New Website',
assigneeId: [2],
roomId: 3,
priorityId: 1,
startDate: new Date('2021-04-30T19:20:00.000Z'),
endDate: new Date('2021-04-30T21:00:00.000Z'),
},
];
export const assignees = [
{
text: 'Samantha Bright',
id: 1,
color: '#C2185B',
}, {
text: 'John Heart',
id: 2,
color: '#1564C0',
}, {
text: 'Todd Hoffman',
id: 3,
color: '#2E7D32',
}, {
text: 'Sandra Johnson',
id: 4,
color: '#7B1FA2',
},
];
export const rooms = [
{
text: 'Room 1',
id: 1,
color: '#00af2c',
}, {
text: 'Room 2',
id: 2,
color: '#2E7D32',
}, {
text: 'Room 3',
id: 3,
color: '#8ecd3c',
},
];
export const priorities = [
{
text: 'High',
id: 1,
color: '#C62828',
}, {
text: 'Low',
id: 2,
color: '#DD2C00',
},
];
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App.js';
ReactDOM.render(<App />, document.getElementById('app'));
export const resourcesList = ['Assignee', 'Room', 'Priority'];
export const data = [
{
text: 'Website Re-Design Plan',
assigneeId: [4],
roomId: 1,
priorityId: 2,
startDate: new Date('2021-04-26T16:30:00.000Z'),
endDate: new Date('2021-04-26T18:30:00.000Z'),
},
{
text: 'Book Flights to San Fran for Sales Trip',
assigneeId: [2],
roomId: 2,
priorityId: 1,
startDate: new Date('2021-04-26T19:00:00.000Z'),
endDate: new Date('2021-04-26T20:00:00.000Z'),
allDay: true,
},
{
text: 'Install New Router in Dev Room',
assigneeId: [1],
roomId: 1,
priorityId: 2,
startDate: new Date('2021-04-26T21:30:00.000Z'),
endDate: new Date('2021-04-26T22:30:00.000Z'),
},
{
text: 'Approve Personal Computer Upgrade Plan',
assigneeId: [3],
roomId: 2,
priorityId: 2,
startDate: new Date('2021-04-27T17:00:00.000Z'),
endDate: new Date('2021-04-27T18:00:00.000Z'),
},
{
text: 'Final Budget Review',
assigneeId: [1],
roomId: 1,
priorityId: 1,
startDate: new Date('2021-04-27T19:00:00.000Z'),
endDate: new Date('2021-04-27T20:35:00.000Z'),
},
{
text: 'New Brochures',
assigneeId: [4],
roomId: 3,
priorityId: 2,
startDate: new Date('2021-04-27T21:30:00.000Z'),
endDate: new Date('2021-04-27T22:45:00.000Z'),
},
{
text: 'Install New Database',
assigneeId: [2],
roomId: 3,
priorityId: 1,
startDate: new Date('2021-04-28T16:45:00.000Z'),
endDate: new Date('2021-04-28T18:15:00.000Z'),
},
{
text: 'Approve New Online Marketing Strategy',
assigneeId: [4],
roomId: 2,
priorityId: 1,
startDate: new Date('2021-04-28T19:00:00.000Z'),
endDate: new Date('2021-04-28T21:00:00.000Z'),
},
{
text: 'Upgrade Personal Computers',
assigneeId: [2],
roomId: 2,
priorityId: 2,
startDate: new Date('2021-04-28T22:15:00.000Z'),
endDate: new Date('2021-04-28T23:30:00.000Z'),
},
{
text: 'Customer Workshop',
assigneeId: [3],
roomId: 3,
priorityId: 1,
startDate: new Date('2021-04-29T18:00:00.000Z'),
endDate: new Date('2021-04-29T19:00:00.000Z'),
allDay: true,
},
{
text: 'Prepare 2021 Marketing Plan',
assigneeId: [1],
roomId: 1,
priorityId: 2,
startDate: new Date('2021-04-29T18:00:00.000Z'),
endDate: new Date('2021-04-29T20:30:00.000Z'),
},
{
text: 'Brochure Design Review',
assigneeId: [4],
roomId: 1,
priorityId: 1,
startDate: new Date('2021-04-29T21:00:00.000Z'),
endDate: new Date('2021-04-29T22:30:00.000Z'),
},
{
text: 'Create Icons for Website',
assigneeId: [3],
roomId: 3,
priorityId: 1,
startDate: new Date('2021-04-30T17:00:00.000Z'),
endDate: new Date('2021-04-30T18:30:00.000Z'),
},
{
text: 'Upgrade Server Hardware',
assigneeId: [4],
roomId: 2,
priorityId: 2,
startDate: new Date('2021-04-30T21:30:00.000Z'),
endDate: new Date('2021-04-30T23:00:00.000Z'),
},
{
text: 'Submit New Website Design',
assigneeId: [1],
roomId: 1,
priorityId: 2,
startDate: new Date('2021-04-30T23:30:00.000Z'),
endDate: new Date('2021-05-01T01:00:00.000Z'),
},
{
text: 'Launch New Website',
assigneeId: [2],
roomId: 3,
priorityId: 1,
startDate: new Date('2021-04-30T19:20:00.000Z'),
endDate: new Date('2021-04-30T21:00:00.000Z'),
},
];
export const assignees = [
{
text: 'Samantha Bright',
id: 1,
color: '#C2185B',
},
{
text: 'John Heart',
id: 2,
color: '#1564C0',
},
{
text: 'Todd Hoffman',
id: 3,
color: '#2E7D32',
},
{
text: 'Sandra Johnson',
id: 4,
color: '#7B1FA2',
},
];
export const rooms = [
{
text: 'Room 1',
id: 1,
color: '#00af2c',
},
{
text: 'Room 2',
id: 2,
color: '#2E7D32',
},
{
text: 'Room 3',
id: 3,
color: '#8ecd3c',
},
];
export const priorities = [
{
text: 'High',
id: 1,
color: '#C62828',
},
{
text: 'Low',
id: 2,
color: '#DD2C00',
},
];
<!DOCTYPE html>
<html lang="en">
<head>
<title>DevExtreme Demo</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" />
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/26.1.5/css/dx.light.css" />
<link rel="stylesheet" type="text/css" href="./bundle.css" />
</head>
<body class="dx-viewport">
<div class="demo-container">
<div id="app"></div>
</div>
<script src="bundles/vendor/react.vendor.js"></script>
<script src="./bundle.js"></script>
</body>
</html>
.options {
padding: 20px;
background-color: rgba(191, 191, 191, 0.15);
margin-top: 20px;
}
.caption {
font-size: 18px;
font-weight: 500;
}
.option {
margin-top: 10px;
display: inline-block;
}