MkTablePage.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import React from 'react'
  2. import { MkTable } from '@mokkon/reactjs'
  3. import '@mokkon/reactjs/dist/index.css';
  4. import { Grid } from '@material-ui/core';
  5. // import theme from '../theme';
  6. function createData(name, calories, fat, carbs, protein) {
  7. return { name, calories, fat, carbs, protein };
  8. }
  9. const rows = [
  10. createData('Cupcake', 305, 3.7, 67, 4.3),
  11. createData('Donut', 452, 25.0, 51, 4.9),
  12. createData('Eclair', 262, 16.0, 24, 6.0),
  13. createData('Frozen yoghurt', 159, 6.0, 24, 4.0),
  14. createData('Gingerbread', 356, 16.0, 49, 3.9),
  15. createData('Honeycomb', 408, 3.2, 87, 6.5),
  16. createData('Ice cream sandwich', 237, 9.0, 37, 4.3),
  17. createData('Jelly Bean', 375, 0.0, 94, 0.0),
  18. createData('KitKat', 518, 26.0, 65, 7.0),
  19. createData('Lollipop', 392, 0.2, 98, 0.0),
  20. createData('Marshmallow', 318, 0, 81, 2.0),
  21. createData('Nougat', 360, 19.0, 9, 37.0),
  22. createData('Oreo', 437, 18.0, 63, 4.0),
  23. ];
  24. const MkTablePage = (props) => {
  25. const [page, setPage] = React.useState(0);
  26. const [rowsPerPage, setRowsPerPage] = React.useState(10);
  27. const headCells = [
  28. { id: 'sr', numeric: true, disablePadding: false, label: 'No.' },
  29. { id: 'name', numeric: false, disablePadding: false, label: 'Name', width: '200px' },
  30. ];
  31. var actions = [{ "action_name": "delete", "display_name": "Delete", }];
  32. const handleChangePaginatePage = (v) => {
  33. setPage(v);
  34. console.log('handleChangePaginatePage :', page);
  35. }
  36. const handleRowPerPage = (v) => {
  37. setRowsPerPage(v);
  38. console.log('handleRowPerPage :', v);
  39. }
  40. const styles = { headerBackgroundColor: 'green', headerTextcolor: 'white' , primaryColor:'lightBlue' };
  41. return (
  42. <div className="root">
  43. {/*table template */}
  44. <Grid container>
  45. <Grid item xs={8}>
  46. <MkTable
  47. // theme={theme}
  48. styles={styles}
  49. headers={headCells}
  50. data={rows}
  51. page={page}
  52. rowsPerPage={rowsPerPage}
  53. order={'asc'}
  54. orderBy={'name'}
  55. actions={actions}
  56. noMoreToLoad={true}
  57. onUpdateDataRow={(d) => { console.log('onUpdateDataRow: ', d) }}
  58. onChangePaginatePage={(newPage) => { handleChangePaginatePage(newPage) }}
  59. onGetData={() => { }}
  60. onChangeRowPerPage={(rowPerPage) => { handleRowPerPage(rowPerPage) }}
  61. ></MkTable>
  62. </Grid>
  63. </Grid>
  64. </div>);
  65. }
  66. export default (MkTablePage);