|
import * as React from 'react';
import './App.css';
import {
ScheduleComponent, Day, Week, WorkWeek, Month, Agenda, Inject, EJ2Instance
} from '@syncfusion/ej2-react-schedule';
import { DateTimePicker } from '../node_modules/@syncfusion/ej2-calendars';
export default class App extends React.Component<{}, {}> {
---------------------
---------------------
---------------------
public render() {
return (
<ScheduleComponent popupOpen={this.onPopupOpen} eventSettings={{
dataSource: this.data,
fields: {
id: 'Id',
subject: { name: 'Subject' },
isAllDay: { name: 'IsAllDay' },
startTime: { name: 'StartTime' },
endTime: { name: 'EndTime', validation: { required: true, minLength: [this.minValidation, 'The selected end date occurs before the start date.'] } }
}
}} width="100%">
<Inject services={[Day, Week, WorkWeek, Month, Agenda]} />
</ScheduleComponent>
);
}
public minValidation: (args: { [key: string]: string }) => boolean = (args: { [key: string]: string }) => {
const startElement: HTMLElement = document.getElementsByName("StartTime")[0] as HTMLElement;
const startDateObj: DateTimePicker = ((startElement as EJ2Instance).ej2_instances[0] as DateTimePicker);
const startValue: Date = startDateObj.value;
const endElement: HTMLElement = document.getElementsByName("EndTime")[0] as HTMLElement;
const endDateObj: DateTimePicker = ((endElement as EJ2Instance).ej2_instances[0] as DateTimePicker);
const endValue: Date = endDateObj.value;
return endValue.getTime() > startValue.getTime();
};
}
|