Search results

Trace events of ProgressButton in React ProgressButton component

The ProgressButton component triggers events based on its actions. The events can be used as extension points to perform custom operations.

The events available in ProgressButton are fail, begin, progress, and end.

Source
Preview
app.tsx
index.html
app.jsx
import { ProgressButtonComponent, ProgressEventArgs } from '@syncfusion/ej2-react-splitbuttons';
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import * as React from 'react';
import * as ReactDom from 'react-dom';

class App extends React.Component<{}, {eventTrace: string}> {
    constructor(props: any) {
        super(props);
        this.state = {
            eventTrace: ''
        }
        this.begin = this.begin.bind(this);
        this.end = this.end.bind(this);
        this.progress = this.progress.bind(this);
        this.fail = this.fail.bind(this);
        this.btnClick = this.btnClick.bind(this);
    }

    public begin(args: ProgressEventArgs): void {
        this.updateEventLog(args);
    }
    public end(args: ProgressEventArgs): void {
        this.updateEventLog(args);
    }
    public progress(args: ProgressEventArgs): void {
        this.updateEventLog(args);
    }
    public fail(args: Event): void {
        this.updateEventLog(args);
    }
    public updateEventLog(args: any): void {
       this.setState({ eventTrace: this.state.eventTrace + args.name + ' Event triggered. <br />' });
    }

    public btnClick(): void {
        this.setState({ eventTrace: '' });
    }

  public render() {
    return (
        <div className='control-section'>
            <div className='progress-btn-section'>
                <ProgressButtonComponent content='Progress' enableProgress = {true} begin={this.begin} end={this.end} progress={this.progress} fail={this.fail}/>
            </div>
            <div className='property-section'>
                <table id='propertyTable' title='Event trace'>
                    <tbody>
                        <th>Event trace:-</th>
                        <tr>
                            <td dangerouslySetInnerHTML={{__html: this.state.eventTrace}}/>
                        </tr>
                    </tbody>
                </table>
            </div>
            <ButtonComponent id='clear' cssClass='e-small' content='Clear' onClick={this.btnClick.bind(this)}/>
        </div>
    );
  }
}
ReactDom.render(<App />, document.getElementById('progress-button'));
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Syncfusion React Progress Button</title>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content="This demo for React Progress button has progress indicator and spinner. It supports texts, icons, styles, sizes, positions, and its customization." />
    <meta name="author" content="Syncfusion" />
    <link href="//cdn.syncfusion.com/ej2/ej2-base/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/ej2-buttons/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/ej2-popups/styles/material.css" rel="stylesheet" />
    <link href="//cdn.syncfusion.com/ej2/ej2-splitbuttons/styles/material.css" rel="stylesheet" />
    <link href="index.css" rel="stylesheet" />
    <link href="spinner.css" rel="stylesheet" />
    <link href="progress.css" rel="stylesheet" />
    <link href="icon.css" rel="stylesheet" />
    <link href="events.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
    <script src="systemjs.config.js"></script>
</head>

<body>
        <div id='progress-button'>
            <div id='loader'>Loading....</div>
        </div>
</body>

</html>
import { ProgressButtonComponent } from '@syncfusion/ej2-react-splitbuttons';
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import * as React from 'react';
import * as ReactDom from 'react-dom';
class App extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            eventTrace: ''
        };
        this.begin = this.begin.bind(this);
        this.end = this.end.bind(this);
        this.progress = this.progress.bind(this);
        this.fail = this.fail.bind(this);
        this.btnClick = this.btnClick.bind(this);
    }
    begin(args) {
        this.updateEventLog(args);
    }
    end(args) {
        this.updateEventLog(args);
    }
    progress(args) {
        this.updateEventLog(args);
    }
    fail(args) {
        this.updateEventLog(args);
    }
    updateEventLog(args) {
        this.setState({ eventTrace: this.state.eventTrace + args.name + ' Event triggered. <br />' });
    }
    btnClick() {
        this.setState({ eventTrace: '' });
    }
    render() {
        return (<div className='control-section'>
            <div className='progress-btn-section'>
                <ProgressButtonComponent content='Progress' enableProgress={true} begin={this.begin} end={this.end} progress={this.progress} fail={this.fail}/>
            </div>
            <div className='property-section'>
                <table id='propertyTable' title='Event trace'>
                    <tbody>
                        <th>Event trace:-</th>
                        <tr>
                            <td dangerouslySetInnerHTML={{ __html: this.state.eventTrace }}/>
                        </tr>
                    </tbody>
                </table>
            </div>
            <ButtonComponent id='clear' cssClass='e-small' content='Clear' onClick={this.btnClick.bind(this)}/>
        </div>);
    }
}
ReactDom.render(<App />, document.getElementById('progress-button'));