I Tried to generate buttons in react but i can't please help me to create export buttons in react

I Tried to generate buttons in react but i can't please help me to create export buttons in react

MAHESH54MAHESH54 Posts: 1Questions: 1Answers: 0
edited September 2018 in Free community support
import React, { Component } from 'react';
import $ from 'jquery';
import 'datatables.net';
import 'datatables.net-bs4';
import 'pdfmake/build/pdfmake.js';
import 'pdfmake/build/vfs_fonts.js';
import 'datatables.net-buttons-bs4';
import 'jszip';
import 'datatables.net-buttons';

class App extends Component {
  update = () =>{

    $(document).ready(function() {
       var table = $('#nirmal').DataTable();
       new $.fn.dataTable.Buttons( table, {
        buttons: [
            'copy', 'excel', 'pdf'
        ]
    } );
      
  });

  }
  componentDidMount(){
    this.update();
  }
  componentDidUpdate(){
    this.update();
  }
  render() {
  
    return (
      <div className="App">
        <table className="table table-striped table-hover" id="nirmal">
          <thead>
            <tr>
              <td>S.No</td>
              <td>Name</td>
              <td>Roll. No</td>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>1</td>
              <td>Nirmalmahesh S</td>
              <td>17MCR005</td>
            </tr>
          </tbody>
        </table>
      </div>
    );
  }
}

export default App;

Answers

Sign In or Register to comment.