|
| 1 | +import React from 'react'; |
| 2 | +import ReactDOM from 'react-dom'; |
| 3 | +import MUIDataTable from '../../src/'; |
| 4 | + |
| 5 | +class Example extends React.Component { |
| 6 | + render() { |
| 7 | + const columns = ['Name', 'Teste', 'Title', 'Location', 'Age', { name: 'Salary', options: { hint: 'USD / year' } }]; |
| 8 | + |
| 9 | + const data = [ |
| 10 | + ['Gabby George', '', 'Business Analyst', 'Minneapolis', 30, 100000], |
| 11 | + ['Aiden Lloyd', '', 'Business Consultant', 'Dallas', 55, 200000], |
| 12 | + ['Jaden Collins', '', 'Attorney', 'Santa Ana', 27, 500000], |
| 13 | + ['Franky Rees', '', 'Business Analyst', 'St. Petersburg', 22, 50000], |
| 14 | + ['Aaren Rose', '', 'Business Consultant', 'Toledo', 28, 75000], |
| 15 | + ['Blake Duncan', '', 'Business Management Analyst', 'San Diego', 65, 94000], |
| 16 | + ['Frankie Parry', '', 'Agency Legal Counsel', 'Jacksonville', 71, 210000], |
| 17 | + ['Lane Wilson', '', 'Commercial Specialist', 'Omaha', 19, 65000], |
| 18 | + ['Robin Duncan', '', 'Business Analyst', 'Los Angeles', 20, 77000], |
| 19 | + ['Mel Brooks', '', 'Business Consultant', 'Oklahoma City', 37, 135000], |
| 20 | + ['Harper White', '', 'Attorney', 'Pittsburgh', 52, 420000], |
| 21 | + ['Kris Humphrey', '', 'Agency Legal Counsel', 'Laredo', 30, 150000], |
| 22 | + ['Frankie Long', '', 'Industrial Analyst', 'Austin', 31, 170000], |
| 23 | + ['Brynn Robbins', '', 'Business Analyst', 'Norfolk', 22, 90000], |
| 24 | + ['Justice Mann', '', 'Business Consultant', 'Chicago', 24, 133000], |
| 25 | + ['Addison Navarro', '', 'Business Management Analyst', 'New York', 50, 295000], |
| 26 | + ['Jesse Welch', '', 'Agency Legal Counsel', 'Seattle', 28, 200000], |
| 27 | + ['Eli Mejia', '', 'Commercial Specialist', 'Long Beach', 65, 400000], |
| 28 | + ['Gene Leblanc', '', 'Industrial Analyst', 'Hartford', 34, 110000], |
| 29 | + ['Danny Leon', '', 'Computer Scientist', 'Newark', 60, 220000], |
| 30 | + ['Lane Lee', '', 'Corporate Counselor', 'Cincinnati', 52, 180000], |
| 31 | + ['Jesse Hall', '', 'Business Analyst', 'Baltimore', 44, 99000], |
| 32 | + ['Danni Hudson', '', 'Agency Legal Counsel', 'Tampa', 37, 90000], |
| 33 | + ['Terry Macdonald', '', 'Commercial Specialist', 'Miami', 39, 140000], |
| 34 | + ['Justice Mccarthy', '', 'Attorney', 'Tucson', 26, 330000], |
| 35 | + ['Silver Carey', '', 'Computer Scientist', 'Memphis', 47, 250000], |
| 36 | + ['Franky Miles', '', 'Industrial Analyst', 'Buffalo', 49, 190000], |
| 37 | + ['Glen Nixon', '', 'Corporate Counselor', 'Arlington', 44, 80000], |
| 38 | + ['Gabby Strickland', '', 'Business Process Consultant', 'Scottsdale', 26, 45000], |
| 39 | + ['Mason Ray', '', 'Computer Scientist', 'San Francisco', 39, 142000], |
| 40 | + ]; |
| 41 | + |
| 42 | + const options = { |
| 43 | + filter: true, |
| 44 | + selectableRows: true, |
| 45 | + filterType: 'dropdown', |
| 46 | + responsive: 'stacked', |
| 47 | + rowsPerPage: 10, |
| 48 | + onRowsSelect: (rowsSelected, allRows) => { |
| 49 | + console.log(rowsSelected, allRows); |
| 50 | + }, |
| 51 | + onRowsDelete: rowsDeleted => { |
| 52 | + console.log(rowsDeleted, 'were deleted!'); |
| 53 | + }, |
| 54 | + onChangePage: numberRows => { |
| 55 | + console.log(numberRows); |
| 56 | + }, |
| 57 | + onSearchChange: searchText => { |
| 58 | + console.log(searchText); |
| 59 | + }, |
| 60 | + onColumnSortChange: (column, direction) => { |
| 61 | + console.log(column, direction); |
| 62 | + }, |
| 63 | + onColumnViewChange: (column, action) => { |
| 64 | + console.log(column, action); |
| 65 | + }, |
| 66 | + onFilterChange: (column, filters) => { |
| 67 | + console.log(column, filters); |
| 68 | + }, |
| 69 | + onCellClick: (cellIndex, rowIndex) => { |
| 70 | + console.log(cellIndex, rowIndex); |
| 71 | + }, |
| 72 | + onRowClick: (rowData, rowState) => { |
| 73 | + console.log(rowData, rowState); |
| 74 | + }, |
| 75 | + isRowSelectable: dataIndex => { |
| 76 | + //prevents selection of row with title "Attorney" |
| 77 | + return data[dataIndex][1] != 'Attorney'; |
| 78 | + }, |
| 79 | + }; |
| 80 | + |
| 81 | + return ( |
| 82 | + <div> |
| 83 | + <MUIDataTable |
| 84 | + title={'ACME Employee list'} |
| 85 | + data={data} |
| 86 | + columns={columns} |
| 87 | + options={{ ...options, radio: true }} |
| 88 | + /> |
| 89 | + <br /> |
| 90 | + <MUIDataTable title={'ACME Employee list'} data={data} columns={columns} options={options} /> |
| 91 | + </div> |
| 92 | + ); |
| 93 | + } |
| 94 | +} |
| 95 | + |
| 96 | +ReactDOM.render(<Example />, document.getElementById('app-root')); |
0 commit comments