1.7.8 • Published 3 months ago

@oniti/datatable-material v1.7.8

Weekly downloads
12
License
MIT
Repository
-
Last release
3 months ago

Datatable Material-Ui

N|Solid

Installation

$ npm install @oniti/datatable-material --save

Exemple

import React, {Component} from 'react';
import {DataTable, Cell} from '@oniti/datatable-material';
import {withStyles} from '@material-ui/core/styles';
import { Grid } from '@material-ui/core';

class Test extends Component {
  state = {
    datas:[
      {
        "_id": "5b1804dd6556c8a70e9198c9",
        "balance": "$1,421.97",
        "picture": "http://placehold.it/32x32",
        "age": 38,
        "name": "Moss Clemons",
        "gender": "male",
        "email": "mossclemons@earthplex.com",
        "phone": "+1 (863) 517-3635"
      },
      {
        "_id": "5b1804dd0dc499695c8f50a3",
        "balance": "$1,203.60",
        "picture": "http://placehold.it/32x32",
        "age": 25,
        "name": "Burton Lane",
        "gender": "male",
        "email": "burtonlane@earthplex.com",
        "phone": "+1 (838) 461-3237"
      },
      {
        "_id": "5b1804dd204f86c6f0fdbe3a",
        "balance": "$3,692.59",
        "picture": "http://placehold.it/32x32",
        "age": 34,
        "name": "Susanne Whitley",
        "gender": "female",
        "email": "susannewhitley@earthplex.com",
        "phone": "+1 (829) 551-2760"
      },
      {
        "_id": "5b1804dd3beda89b69fc0858",
        "balance": "$3,337.96",
        "picture": "http://placehold.it/32x32",
        "age": 20,
        "name": "Marquez Roman",
        "gender": "male",
        "email": "marquezroman@earthplex.com",
        "phone": "+1 (955) 542-3013"
      },
      {
        "_id": "5b1804dd111b3914d3305175",
        "balance": "$1,860.26",
        "picture": "http://placehold.it/32x32",
        "age": 30,
        "name": "Veronica Schwartz",
        "gender": "female",
        "email": "veronicaschwartz@earthplex.com",
        "phone": "+1 (825) 561-2393"
      }
    ]
  }

  formatPicture(user){
    return <img src={user.picture} alt={user.name} />;
  }
  render() {
    const {classes} = this.props

    return (
      <div className={classes.root}>
        <Grid container spacing={2}>
          <Grid item xs={12}>
            <DataTable
            datas={this.state.datas}
            showPagination={true}
            showSearch={true}
            defaultSort="name"

            >
              <Cell
                title="Picture"
                format={this.formatPicture}
              />
              <Cell
              datakey="name"
              title="Name"
              sortable={true}
              searchable={true}
              />
              <Cell
              datakey="gender"
              title="Gender"
              sortable={true}
              searchable={true}
              />
              <Cell
              datakey="email"
              title="Email"
              sortable={true}
              searchable={true}
              />

            </DataTable>
          </Grid>
        </Grid>
      </div>
    );
  }
}
const style = theme => ({
  root: {
    flexGrow: 1
  },
})
export default withStyles()(Test)

Props

DataTable

NameTypeDescription
datasArray
showPaginationBoolShow pagination
showSearchBoolShow search input
sortTypeString'asc' or 'desc'
defaultSortStringdefaut key for sorting
searchlabelStringLabel for search input, default : "Rechercher"
nodatalabelStringtext for no data , default : "Aucune donnée"
classNameString
labelRowsPerPageStringtext before select row per page, default : "Lignes par page"
labelDisplayedRowsFuncfunction for pagination information, (data) => return data.from + ' - ' + data.to + ' sur ' + data.count
rowsPerPageOptionsArraydefault 5, 10, 25
rowsPerPageIntdefault select rowsPerPageOptions
getStateOnUnmountFunccallback function call on componentWillUnmount return datatable state
initialValuesObjectinitial value to initialize datatable (previous state)
extraNodesArrayElement to insert ex : { element: this.getBtnAdd(), position: 'top-right'}, positions aviables 'top-right', 'top-left'
rowClassNameFuncFunction to return className (obj, key) => className
cancelUpdateCheckBoolCancel shouldUpdate verification
asynchroneBoolSwitch to Async mode
updateDataAsyncFuncAsync mode - Call to update data should return a promise
totalAsyncResultNumberAsync mode - Total of result
loadingBoolAsync mode - loading

Cell

NameTypeDescription
datakeyStringkey of object
titleStringTitle of collumn
formatFuncfunction to render Cell (obj, key) =>
sortableBoolCol sortable
searchableBoolCol searchable
isDateBoolValue is a date
classNameString
useDataKeyOnSearchBoolTo search with datakey value

License

MIT

1.7.8

3 months ago

1.7.7

3 months ago

1.7.6

3 months ago

1.7.5

4 months ago

1.7.4

9 months ago

1.7.3

2 years ago

1.6.11

2 years ago

1.6.10

2 years ago

1.6.13

2 years ago

1.6.12

2 years ago

1.6.15

2 years ago

1.6.14

2 years ago

1.7.2

2 years ago

1.7.1

2 years ago

1.7.0

2 years ago

1.6.9

2 years ago

1.6.8

2 years ago

1.6.7

2 years ago

1.6.4

3 years ago

1.6.3

3 years ago

1.6.2

3 years ago

1.6.1

3 years ago

1.6.6

3 years ago

1.6.5

3 years ago

1.6.0

4 years ago

1.5.9

4 years ago

1.5.8

4 years ago

1.5.7

4 years ago

1.5.6

4 years ago

1.5.5

4 years ago

1.5.4

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

5 years ago

1.4.9

5 years ago

1.4.8

5 years ago

1.4.7

5 years ago

1.4.6

5 years ago

1.4.5

5 years ago

1.4.4

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.15

5 years ago

1.3.14

5 years ago

1.3.13

5 years ago

1.3.12

5 years ago

1.3.11

5 years ago

1.3.10

5 years ago

1.3.9

5 years ago

1.3.8

6 years ago

1.3.7

6 years ago

1.3.6

6 years ago

1.3.5

6 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.7

6 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago