Search results

Read all values of Dialog on button click in React Dialog component

You can read the dialog element values by binding the action handler to the footer buttons. The buttons property provides the options to bind events to the action buttons. For detailed information about buttons, refer to the footer section. In the below sample, value of input elements within the dialog has been checked in the footer button click event and send the values as the content of confirmation dialog.

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import App  from './App';

ReactDOM.render(<App />, document.getElementById('container'));
<!DOCTYPE html>
<html lang="en">

    <title>Syncfusion React Dialog</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="Essential JS 2 for React Components" />
    <meta name="author" content="Syncfusion" />
    <link href="styles.css" rel="stylesheet" />
    <link href="" rel="stylesheet" />
    <link href="//" rel="stylesheet" />
    <link href="//" rel="stylesheet" />
    <link href="//" rel="stylesheet" />
    <link href="//" rel="stylesheet" />
    <script src=""></script>
    <script src="systemjs.config.js"></script>

    <div id='container'>
        <div id="dialog"></div>
        <div id="modalDialog"></div>
            <div id='loader'>Loading....</div>

import { DialogComponent } from '@syncfusion/ej2-react-popups';
import * as React from "react";
import './App.css';
class App extends React.Component {
    constructor() {
        this.buttons = [{
                buttonModel: {
                    content: 'Submit',
                    cssClass: 'e-flat',
                    isPrimary: true,
                'click': () => {
    handleClick() {;
    nestedbuttonClick() {
    footerbuttonclick() {
    dialogContent() {
        return (<form>
        <div className='form-group'>
            <input type='name' className='form-control' id='name' ref={n => this.nameInput = n}/>
        <div className='form-group'>
            <label>Email Id:</label>
            <input type='email' placeholder='' className='form-control' id='email' ref={e => this.emailInput = e}/>
        <div className='form-group'>
            <label>Contact Number:</label>
            <input type='contact' className='form-control' id='contact' ref={c => this.contactInput = c}/>
        <div className='form-group'><label>Address:</label>
            <textarea className='form-control' id='address' ref={a => this.addressInput = a}/>
    dlgbuttonClick() {
        this.innerDialogInstance.content = this.getDynamicContent();
        this.innerDialogInstance.buttons = [{ click: this.footerbuttonclick.bind(this), buttonModel: { content: 'Yes', isPrimary: true } },
            { click: this.nestedbuttonClick.bind(this), buttonModel: { content: 'No', isPrimary: true } }];;
    getDynamicContent() {
        const template = "<div class='row'><div class='col-xs-6 col-sm-6 col-lg-6 col-md-6'><b>Confirm your details</b></div>" +
            "</div><div class='row'><div class='col-xs-6 col-sm-6 col-lg-6 col-md-6'><span id='name'> Name: </span>" +
            "</div><div class='col-xs-6 col-sm-6 col-lg-6 col-md-6'><span id='nameValue'>" + this.nameInput.value + "</span> </div></div>" +
            "<div class='row'><div class='col-xs-6 col-sm-6 col-lg-6 col-md-6'><span id='email'> Email: </span>" +
            "</div><div class='col-xs-6 col-sm-6 col-lg-6 col-md-6'><span id='emailValue'>" + this.emailInput.value +
            "</span></div></div><div class='row'><div class='col-xs-6 col-sm-6 col-lg-6 col-md-6'>" +
            "<span id='Contact'> Contact number: </span></div><div class='col-xs-6 col-sm-6 col-lg-6 col-md-6'>" +
            "<span id='contactValue'>" + this.contactInput.value + " </span></div></div><div class='row'><div class='col-xs-6 col-sm-6 col-lg-6 col-md-6'>" +
            "<span id='Address'> Address: </span> </div><div class='col-xs-6 col-sm-6 col-lg-6 col-md-6'><span id='AddressValue'>" + this.addressInput.value + "</span></div></div>";
        return template;
    render() {
        return (<div className="App" id='dialog-target'>
      <button className='e-control e-btn' id='targetButton1' role='button' onClick={this.handleClick = this.handleClick.bind(this)}>Open</button>

      <DialogComponent id='dialog' width='400px' target='#dialog-target' header='Dialog' visible={false} closeOnEscape={false} showCloseIcon={true} buttons={this.buttons} ref={dialog => this.dialogInstance = dialog}>

      <DialogComponent id='innerDialog' header='User details' isModal={true} showCloseIcon={true} width='400px' visible={false} ref={dialog => this.innerDialogInstance = dialog} closeOnEscape={false} target='#dialog-target'/>
export default App;