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 pathmultiple-dialogs.tsx
More file actions
96 lines (91 loc) · 4.24 KB
/
multiple-dialogs.tsx
File metadata and controls
96 lines (91 loc) · 4.24 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
import * as ReactDOM from 'react-dom';
import * as React from 'react';
import { DialogComponent } from '@syncfusion/ej2-react-popups';
import { SampleBase } from '../common/sample-base';
import './multiple-dialogs.css';
export class MultipleDialogs extends SampleBase<{}, {hideDialog1: boolean, hideDialog2: boolean;}> {
private defaultDialogInstance: DialogComponent;
private secondDialogInstance: DialogComponent;
private dlgButton: Object[];
private dlg2Button: Object[];
private animationSettings: Object;
private buttonRef;
private buttonElement: HTMLElement;
constructor(props: {}) {
super(props);
this.state = {
hideDialog1 : true,
hideDialog2 : false
};
this.buttonElement = null;
this.buttonRef = element => {
this.buttonElement = element;
};
this.dlgButton = [{
click: () => {
this.setState({ hideDialog2: true });
},
buttonModel: { content: 'Next', isPrimary: true }
}];
this.dlg2Button = [{
click: () => {
this.setState({ hideDialog2: false });
},
buttonModel: { content: 'Close', isPrimary: true }
}];
this.animationSettings = { effect: 'None' };
}
private buttonClick(args:any): void {
this.setState({ hideDialog1: true });
}
private dialogClose(): void {
this.setState({ hideDialog1: false });
this.buttonElement.style.display='inline-block';
}
private dialogClose2(): void {
this.setState({ hideDialog2: false });
this.buttonElement.style.display='none';
}
private dialogOpen(): void {
this.buttonElement.style.display='none';
}
public render(): JSX.Element {
return (
<div className = 'control-pane'>
<div id='target' className='col-lg-12 control-section dialog-target'>
<button className='e-control e-btn dlgbtn' ref={this.buttonRef} onClick={this.buttonClick.bind(this)} id='dialogBtn'>Open Dialog</button>
{/* Render alert Dialog */}
<DialogComponent id='defaultDlg' header='First Dialog' visible={this.state.hideDialog1} showCloseIcon={true} animationSettings={this.animationSettings} width='330px' ref={defaultDialog => this.defaultDialogInstance = defaultDialog}
target='#target' buttons={this.dlgButton} open={this.dialogOpen.bind(this)} close={this.dialogClose.bind(this)}>
<p>
This is the first dialog and acts as a parent dialog, you can open the second (child) dialog by clicking "Next".
</p>
</DialogComponent>
{/* Render confirmation Dialog */}
<DialogComponent id='secondDialog' isModal={true} header='Second Dialog' showCloseIcon={true} visible={this.state.hideDialog2} animationSettings={this.animationSettings} width='285px' ref={secondDialog => this.secondDialogInstance = secondDialog}
target='#target' buttons={this.dlg2Button} open={this.dialogOpen.bind(this)} close={this.dialogClose2.bind(this)}>
<p>
This is the second dialog and act as a child dialog.
</p>
</DialogComponent>
<div id="action-description">
<p>
This sample demonstrates how to display multiple dialogs one over the other.
The second dialog is configured with draggable behavior to adjust its position.
You can invoke the second dialog from first dialog's button.
Enable the "open dialog" button to reopen the dialog if the first dialog is closed.
</p>
</div>
<div id="description">
<p>
You can configure the dialog as a parent and child, and invoke the child dialog from its parent dialog.
In addition, multiple dialogs can be shown at a time in a page.
The Z- index order will be controlled automatically in the browser and manually using the<a target="_blank"
href="https://ej2.syncfusion.com/react/documentation/dialog/api-dialogComponent.html#zindex"> zIndex </a> property.
</p>
</div>
</div>
</div>
);
}
}