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 pathnode-editing.tsx
More file actions
74 lines (72 loc) · 2.88 KB
/
node-editing.tsx
File metadata and controls
74 lines (72 loc) · 2.88 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
import * as ReactDOM from 'react-dom';
import * as React from 'react';
import { SampleBase } from '../common/sample-base';
import {TreeViewComponent} from '@syncfusion/ej2-react-navigations';
import './treeview.css';
export class Editing extends SampleBase<{}, {}> {
public treeData: { [key: string]: Object }[] = [
{
id: 1, name: 'Discover Music', expanded: true,
child: [
{ id: 2, name: 'Hot Singles' },
{ id: 3, name: 'Rising Artists' },
{ id: 4, name: 'Live Music' }
]
},
{
id: 7, name: 'Sales and Events',
child: [
{ id: 8, name: '100 Albums - $5 Each' },
{ id: 9, name: 'Hip-Hop and R&B Sale' },
{ id: 10, name: 'CD Deals' }
]
},
{
id: 11, name: 'Categories',
child: [
{ id: 12, name: 'Songs' },
{ id: 13, name: 'Bestselling Albums' },
{ id: 14, name: 'New Releases' },
{ id: 15, name: 'Bestselling Songs' }
]
},
{
id: 16, name: 'MP3 Albums',
child: [
{ id: 17, name: 'Rock' },
{ id: 18, name: 'Gospel' },
{ id: 19, name: 'Latin Music' },
{ id: 20, name: 'Jazz' }
]
},
{
id: 21, name: 'More in Music',
child: [
{ id: 22, name: 'Music Trade-In' },
{ id: 23, name: 'Redeem a Gift Card' },
{ id: 24, name: 'Band T-Shirts' }
]
}
];
private fields: Object = { dataSource: this.treeData, id: 'id', text: 'name', child: 'child' };
private allowEditing:boolean = true;
render() {
return (
<div className = 'control-pane'>
<div className='control-section'>
<div className='tree-control_wrapper'>
{/* Render the TreeView with editing option */}
<TreeViewComponent fields={this.fields} allowEditing={this.allowEditing}/>
</div>
</div>
<div id="action-description">
<p>This sample demonstrates the node editing functionalities of the TreeView. Double click on the node or press F2 key on selected node to edit node's text in input textbox. Press enter key or click outside of the input element to save the node's, or press escape key to cancel the modified text.</p>
</div>
<div id="description">
<p>The <code>TreeView</code> component has the built-in option to edit and modify the node text in inline by enabling the <code>allowEditing</code> property.</p>
<p>For more information, you can refer to the <a href="http://ej2.syncfusion.com/react/documentation/treeview/node-edit.html" target="_blank">Node Editing</a> section from the documentation.</p>
</div>
</div>
)
}
}