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 pathdefault.tsx
More file actions
88 lines (83 loc) · 3.97 KB
/
default.tsx
File metadata and controls
88 lines (83 loc) · 3.97 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
/**
* DropDownList Default Sample
*/
import * as ReactDOM from 'react-dom';
import * as React from 'react';
import { DropDownListComponent } from '@syncfusion/ej2-react-dropdowns';
import { SampleBase } from '../common/sample-base';
import { PropertyPane } from '../common/property-pane';
import './default.css';
export class Default extends SampleBase<{}, {}> {
private listObj: DropDownListComponent;
// define the JSON of data
private sportsData: { [key: string]: Object }[] = [
{ Id: 'Game1', Game: 'American Football' },
{ Id: 'Game2', Game: 'Badminton' },
{ Id: 'Game3', Game: 'Basketball' },
{ Id: 'Game4', Game: 'Cricket' },
{ Id: 'Game5', Game: 'Football' },
{ Id: 'Game6', Game: 'Golf' },
{ Id: 'Game7', Game: 'Hockey' },
{ Id: 'Game8', Game: 'Rugby' },
{ Id: 'Game9', Game: 'Snooker' },
{ Id: 'Game10', Game: 'Tennis' }
];
// maps the appropriate column to fields property
private fields: object = { text: 'Game', value: 'Id' };
// set the value to select an item based on mapped value at initial rendering
private value: string = 'Game3';
public onChange(): void {
let value: Element = document.getElementById('value');
let text: Element = document.getElementById('text');
// update the text and value property values in property panel based on selected item in DropDownList
value.innerHTML = this.listObj.value === null ? 'null' : this.listObj.value.toString();
text.innerHTML = this.listObj.text === null ? 'null' : this.listObj.text;
}
// call the change event's function after initialized the component.
public rendereComplete(): void {
this.onChange();
}
render() {
return (
<div id="dropdowndefault" className='control-pane'>
<div className='control-section'>
<div className='col-lg-8'>
<div className="content-wrapper">
<div id='default'>
<DropDownListComponent id="games" dataSource={this.sportsData} ref={(dropdownlist) => { this.listObj = dropdownlist }} fields={this.fields} change={this.onChange.bind(this)} placeholder="Select a game" value={this.value} popupHeight="220px" />
</div>
</div>
</div>
<div className='col-lg-3 property-section'>
<PropertyPane title='Properties'>
<table id='property' title='Properties' style={{ width: '100%', margin: '10px' }}>
<tr>
<td style={{ padding: '5px', width: '25%' }}>Value</td>
<td>:<span id='value' style={{ paddingLeft: '10px' }}></span></td>
</tr>
<tr>
<td style={{ padding: '5px', width: '25%' }}>Text</td>
<td>:<span id='text' style={{ paddingLeft: '10px' }}></span></td>
</tr>
</table>
</PropertyPane>
</div>
</div>
<div id="action-description">
<p>This sample demonstrates the default functionalities of the DropDownList. Click the DropDownList element and select an item from the <code>options</code> list.
The selected item's <code>value</code> and <code>text</code> property values will be shown the in property panel.</p>
</div>
<div id="description">
<p>The <code>DropDownList</code> component contains a list of predefined values from that the user can choose a single
value. </p>
<p>The default sample illustrates the use of DropDownList that allows the end-users to select an item from the <code>options</code> list. The selected item's <code>value</code> and <code>text</code> property values will be displayed in the property
panel.
</p>
<p> More information on the DropDownList instantiation can be found in the
<a href="http://ej2.syncfusion.com/react/documentation/drop-down-list/getting-started.html" target="_blank"> documentation section</a>.
</p>
</div>
</div>
);
}
}