This repository was archived by the owner on Jul 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdate-format.tsx
More file actions
61 lines (58 loc) · 2.8 KB
/
date-format.tsx
File metadata and controls
61 lines (58 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import * as ReactDOM from 'react-dom';
import * as React from 'react';
import './datepicker-component.css';
import { DatePickerComponent, RenderDayCellEventArgs, ChangedEventArgs } from '@syncfusion/ej2-react-calendars';
import { DropDownListComponent, ChangeEventArgs } from '@syncfusion/ej2-react-dropdowns';
import { FloatLabelType } from '@syncfusion/ej2-react-inputs';
import { SampleBase } from '../common/sample-base';
import { PropertyPane } from '../common/property-pane';
let dateValue: Date = new Date();
export class Dateformat extends SampleBase<{}, {}> {
private datepickerInstance: DatePickerComponent;
private listObj: DropDownListComponent;
private dataTypes: { [key: string]: Object }[] = [
{ value: 'dd-MMM-yy' },
{ value: 'yyyy-MM-dd' },
{ value: 'dd-MMMM' },
];
private fields: object = { value: 'value' };
public waterMark: string = 'Format';
public floatLabelType: FloatLabelType = 'Auto';
public index: number = 0;
/*Apply selected format to the component*/
public onChange(): void {
let format: any = this.listObj.value;
this.datepickerInstance.format = format;
}
render() {
return (
<div className='control-pane'>
<div className='control-section row'>
<div className='col-lg-8'>
<div className='datepicker-control-section'>
<DatePickerComponent format='dd-MMM-yy' ref={calendar => this.datepickerInstance = calendar} value={dateValue} ></DatePickerComponent>
</div>
</div>
<div id="format" className='col-lg-3 property-section'>
<div>
<DropDownListComponent id="dateFormats" dataSource={this.dataTypes} fields={this.fields} floatLabelType={this.floatLabelType} index={this.index} ref={(dropdownlist) => { this.listObj = dropdownlist }} placeholder={this.waterMark} change={this.onChange.bind(this)}>
</DropDownListComponent>
</div>
</div>
</div>
<div id="action-description">
<p>
In this sample, the DatePicker has been configured with the <code>dd-MMM-yy</code> date format. To change this current date format, go to the properties panel at the right side and select a date format from the dropdown options.</p>
</div>
<div id='description'>
<p>
Format sample illustrates the support of custom date format in the DatePicker component by
using the <code>format</code> property. You can also change the date format by selecting it from the format options in the properties
panel.
</p>
<p> More information on the date format configuration can be found in the <a href="https://ej2.syncfusion.com/react/documentation/datepicker/date-format.html" target="_blank"> documentation section</a>.</p>
</div>
</div>
)
}
}