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 pathapi.tsx
More file actions
152 lines (143 loc) · 7.29 KB
/
api.tsx
File metadata and controls
152 lines (143 loc) · 7.29 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import * as ReactDOM from 'react-dom';
import * as React from 'react';
import { MenuComponent, FieldSettingsModel, Orientation } from '@syncfusion/ej2-react-navigations';
import { DropDownListComponent, ChangeEventArgs as ddlChange, Inject } from '@syncfusion/ej2-react-dropdowns';
import { MultiSelectComponent, MultiSelectChangeEventArgs, CheckBoxSelection } from '@syncfusion/ej2-react-dropdowns';
import { CheckBoxComponent, ChangeEventArgs as cbChange } from '@syncfusion/ej2-react-buttons';
import { PropertyPane } from '../common/property-pane';
import { SampleBase } from '../common/sample-base';
import './api.css';
export class Api extends SampleBase<{}, {}> {
private menuObj: MenuComponent;
//Menu datasource
public data: { [key: string]: Object }[] = [
{
header: 'Events',
subItems: [
{ text: 'Conferences' },
{ text: 'Music' },
{ text: 'Workshops' }
]
},
{
header: 'Movies',
subItems: [
{ text: 'Now Showing' },
{ text: 'Coming Soon' }
]
},
{
header: 'Directory',
subItems: [
{ text: 'Media Gallery' },
{ text: 'Newsletters' }
]
},
{
header: 'Queries',
subItems: [
{ text: 'Our Policy' },
{ text: 'Site Map'},
{ text: '24x7 Support'}
]
},
{ header: 'Services' }
];
//Menu fields definition
public menuFields: FieldSettingsModel = {
iconCss: 'icon',
text: ['header', 'text', 'value'],
children: ['subItems', 'options']
};
//DropDownList datasource
public modeData: { [key: string]: Object }[] = [
{ text: 'Horizontal', value: 'Horizontal' },
{ text: 'Vertical', value: 'Vertical' }
];
public modeChange(args: ddlChange): void {
this.menuObj.orientation = args.itemData.value as Orientation;
}
//MultiSelect datasource
public headerData: { [key: string]: Object }[] = [
{ text: 'Events' }, { text: 'Movies'}, { text: 'Directory' }, { text: 'Queries' }, { text: 'Services' }
];
public enabledisableChange(args: MultiSelectChangeEventArgs): void {
if (args.value) {
this.menuObj.enableItems(['Events', 'Movies', 'Directory', 'Queries', 'Services'], true);
this.menuObj.enableItems(args.value as string[], false);
}
}
//CheckBox change event
public showOnClickChange(args: cbChange) {
this.menuObj.showItemOnClick = args.checked;
}
render() {
return (
<div className='control-pane'>
<div className="menu-section control-section">
<div className="col-lg-8 control-section">
<div id="apiMenu">
<MenuComponent items={this.data} fields={this.menuFields} ref={(scope) => { this.menuObj = scope; }}></MenuComponent>
</div>
</div>
<div className="col-lg-4 property-section">
<PropertyPane title='Properties'>
<table id="property" title="Properties" style={{ width: '100%' }}>
<tbody>
<tr>
<td style={{ width: '50%', paddingTop: '10px' }}>
<div>Orientation</div>
</td>
<td style={{ width: '50%', paddingTop: '10px' }}>
<div style={{ maxWidth: '200px' }}>
<DropDownListComponent value='Horizontal' dataSource={this.modeData} popupHeight='200px' change={this.modeChange.bind(this)}></DropDownListComponent>
</div>
</td>
</tr>
<tr>
<td style={{ width: '50%', paddingTop: '10px' }}>
<div>Enable / Disable item</div>
</td>
<td style={{ width: '50%', paddingTop: '10px' }}>
<div style={{ maxWidth: '200px' }}>
<MultiSelectComponent dataSource={this.headerData} popupHeight='250px' width='160px' mode='CheckBox' placeholder='Select item' showDropDownIcon={true} change={this.enabledisableChange.bind(this)}>
<Inject services={[CheckBoxSelection]}/>
</MultiSelectComponent>
</div>
</td>
</tr>
<tr>
<td style={{ width: '50%', paddingTop: '15px' }}>
<div>Show Item on Click</div>
</td>
<td style={{ width: '50%', paddingTop: '15px' }}>
<CheckBoxComponent checked={false} change={this.showOnClickChange.bind(this)}></CheckBoxComponent>
</td>
</tr>
</tbody>
</table>
</PropertyPane>
</div>
</div>
<div id="action-description">
<p>This sample demonstrates the customization of <code>menu</code> component by using its properties from the property pane. Select any combination of properties from the property pane to customize <code>menu</code> component.</p>
</div>
<div id="description">
<p>In this demo, default menu is rendered with minimal configuration.</p>
<p>This sample can be customized further with the combination of <code>menu</code> properties from the property pane. For example,</p>
<ul>
<li>You can switch to <b>Vertical</b> and <b>Horizontal</b> modes by clicking and selecting the
<code>orientation</code> mode from <i>Orientation</i> dropdownlist.</li>
<li>You can enable or disable menu items by clicking and selecting the item
from <i>Enable item</i> or <i>Disable item</i> dropdownlists.</li>
<li>You can also enable the show menu item on mouse click <code>showItemOnClick</code> property by checking the
<i>Show item on Click</i> checkbox.</li>
</ul>
<p>
More information about menu can be found in this <a target="_blank" href="http://ej2.syncfusion.com/react/documentation/menu/api.html">documentation</a> section.
</p>
</div>
</div>
)
}
}