1.0.29 • Published 4 months ago

@jazasoft/mui-table v1.0.29

Weekly downloads
84
License
MIT
Repository
github
Last release
4 months ago

@jazasoft/mui-table

Advanced React Data Table using Material UI

NPM JavaScript Style Guide

Features

  • Simple Table
  • Collective Editing - Edit entire table at once
  • Sorting
  • Selection
  • Pagination
  • Filter & Search
  • Inline Editing - Edit one row at once
  • Add/Remove Row
  • Horizontal Scroll/ Force Line Wrap on Specified characters
  • Variant - default, excel
  • Tree Table
  • Custom Footer Actions
  • Column selection
  • Spanning - Row Span & Col Span
  • Expandable View/ Modal View/ Sidebar View
  • Fully Customizable
  • Fixed Header
  • Drag & Drop for Editable Tree Data
  • Change Sequence using Drag & Drop
  • Elements
    • TextField
    • TextInput
    • SelectInput
    • BooleanInput
    • AutoCompleteInput
    • On Demand loading from remote for AutoCompleteInput
    • DateInput

Examples

Install

npm install --save @jazasoft/mui-table

Usage

import React, { Component } from 'react'

import { MuiTable } from '@jazasoft/mui-table'

const columns = [
  { dataKey: 'dessert', title: 'Dessert' },
  { dataKey: 'calories', title: 'Calories', align: 'right' },
  { dataKey: 'fat', title: 'Fat (g)', align: 'right' },
  { dataKey: 'carbs', title: 'Carbohydrate (g)', align: 'right' },
  { dataKey: 'protein', title: 'Protein', align: 'right' }
]

const rows = Array(10)
  .fill('')
  .map((_, idx) => ({
    dessert: `Dessert ${idx + 1}`,
    calories: Math.round(Math.random() * 500),
    fat: Math.round(Math.random() * 10),
    carbs: Math.round(Math.random() * 100),
    protein: (Math.random() * 10).toFixed(1)
  }))

class App extends Component {
  render() {
    return <MuiTable columns={columns} rows={rows} />
  }
}

Types

Action

NameTypeDefault ValueDescription
namestringRequired. Name of action
tooltipstringOptional. Tooltip for the action
iconReactElementIcon for this action. Required for custom actions.
optionsobjectoptions will be passed down to Button or IconButton element

Column

NameTypeDefault ValueDescription
dataKeystringKey in Object for this column
titlestringLabel for this column
hiddenbooleanTo hide columns. There are cases where, search and filter on some field is required without showing Column
titleSelectedfunctionTitle when rows are selected. Signature - (selectedRows) => string
inputTypestring'text-field'Type of Input when table is editable. Values - 'text-field', 'text-input', 'select-input', 'boolean-input', 'date-input', 'auto-complete-input'
fetchChoicesfunctionfunction to fetch choices on demand for auto-complete-input. (searchText, rows) => Promise(Choices)
choicesfunction\|object[][]List of Choices when inputType is 'select-input' or 'auto-complete-input'. Object Type - {id: string\|number, name: string}. Function: ({row, rowIdx, rows, colIdx, dataKey}) => object[]
renderfunctionrender function if custom rendering is required. signature - (value) => ?any
validatefunction\|function[]field validation function. (value: ?any, allValues: Object, meta: ?FieldState) => ?any
optionsobject{}props to be passed to underlying editable component - Input, Select, Switch etc
disabledfunctionDisable Editable cells conditionally. Entire columns can be disabled using options.disabled. If both are provided, this func will have high priority. (row, dataKey, rows) => bool
alignstringSame as MUI TableCell Values - inherit, center, justify, left, right
linkPathfunctionIt will turn field to link. (row, dataKey) => Path:String
lengthnumberNo. of characters to show or force text wrap depending on value of cellOverFlow prop of table
filterOptionsobject{}Filter Options - {filter: bool, isCsvText: bool, multiSelect: bool, showValueOnly: bool}
headerCellPropsobject{}MUI Table Cell Props to be passed to Header Cell
rowCellPropsobject{}MUI Table Cell Props to be passed to Row Cell

Props

NameTypeDefault ValueDescription
columnscolumn[][]List of Columns
rowsobject[][]List of objects
toolbarboolfalseWhether to show toolbar
toolbarDividerbooltrueWhether to show Divider between Toolbar and Table Content or not
titlestringMui TableToolbar Title
editableboolfalseTable will become editable
enableRowAdditionboolfalseWhether row addition should be enabled in editable mode.
selectAllbooltrueApplicable only when selectable is true, Select All Support
multiSelectbooltrueWhether multiple selection should be allowed for selectable Table
pageSelectbooltrueWhether only current page should be selected on select all or full table
pageableboolfalseTable will have pagination
rowsPerPageOptionsnumber[][10, 25]PageSize dropdown options
pageSizenumber10Number records to show in one page.
sortableboolfalseColumns will become sortable
isTreeTableboolfalseWhether table is tree table or not?
defaultSort{field: string, order: 'asc\|desc'}Default Sorting. default value is first column in asc order
searchableboolfalseEnable Search in Table
searchKeysstring[]['name']Keys on which search will apply
tablePropsobject{}MUI Table props to be passed to Table
idKeystringidIdentifier Key in row object. This is used for selection and in tree table
totalRowKeystringtotalRowFor flaging a row as total row, set true value in totalRowKey
parnetIdKeystringparentIdIdentifier Key of parent in row object. This is used in tree table
disabledElementstringinputElement to use when editable element is disabled. Values - field, input
cellLengthnumber30Default value of Cell Character Length when cell specific length is not provided
cellOverFlowstringtooltipContent behavior when cell content is greater than cell length. Values - tooltip, wrap
variantstringdefaultSelect Table Variant. Values - default, excel
fontSizenumber12Font Size
emptyMessagestringNo records available!Message when rows is empty
expandedColorstring\|string[]noneBackground Color of Expanded Row. provide array of colors if different color is required for different level
childIndentstring12Left Indentation of Child in pixel
initialExpandedStatestringnullInintial Expanded State. signature - {[idKey]: true\|false}
selectActionsAction[][{name: 'delete'}]Select Actions. Standard actions - add, edit, delete
toolbarActionsAction[][]Toolbar Actions. Standard actions - column. Not Implemented yet
inlineActionsfunction\|Action[][]Inline Actions. Standard actions - add, duplicate, edit, delete.
footerActionsAction[][]Custom Footer Actions. Standard actions - edit.
chipOptionsobject{}options passed to Chip element in FilterList
actionPlacementstringrightPlacement of action buttons. Values - left, right
rowInsertstringbelowPlacement row to insert for add, duplicate inline actions. Values - above, below
rowAddCountnumber3Number of rows to add in editable mode
onRowAddfunctionSignature - (rows, rowIdx, currRow) => Row Object . Can control row to be added on inline row addition or footer row addition
showEditableActionsboolfalseShow actions - add, addChild, delete in editiable mode
showChildAddActionfunctionSignation - (row, rows) => bool
componentstringformHTML element for FormContent
editingboolfalseTo Open Table in Editable mode
defaultExpandedbool \|functiondefault expanded state. Signature - bool \| (row, level) => bool.
selectablebool \| functionfalseSelectable Rows. bool \| (row) => bool
onSubmitfunctionSubmit function to be called when table is editable. (values, form, onSubmitComplete) => {}. call onSubmitComplete with updated rows to indicate that submit is complete
onChangefunctiononChange function to be called when any value changes. (name, value, row, form) => {}.
validatefunctionCalled before onSubmit. (values: FormValues) => Object \| Promise<Object>
comparatorfunction(a, b) => 0Sort Comparator when sortable is false
onSelectActionClickfunctionSignature - (event, action, selectedRows, onActionComplete: func) => void. call onActionComplete to indicate that action is completed
onSelectfunctionFunction called on row select with selected ids. Signature - (selectedIds) => void.
onRowClickfunctionFunction called on row click. Signature - (row) => void.
onFilterfunctionFunction called on filter. Signature - (filterValues) => void.
onToolbarActionClickfunctionSignature - (event, action) => void.
onTreeExpandfunctionFunction called on expand click. Signature - (event, row, isExpanded) => void.
fetchChildrenfunctionFunction called to fetch children if not available. Signature - (row) => childRows \| Promise()
onInlineActionClickfunctionSignature - (event, action, row, onActionComplete: func) => void. call onActionComplete with updated row data after action is completed
onFooterActionClickfunctionSignature - (event, action, rows, onActionComplete: func) => void. call onActionComplete with updated row data after action is completed
rowStyleobject\|function{}Signature - ({row, rowIdx}) => object. function should return style object
headerCellStyleobject\|function{}Signature - ({row, column, rowIdx, colIdx}) => object. function should return style object
cellStyleobject\|function{}Signature - ({row, column, rowIdx, colIdx}) => object. function should return style object
handleSubmitReffunctionSignature - (handleSubmit) => Void. When External Form submit is required, We get hold of React Final Form handleSubmit by calling this method.

License

MIT © Jaza Software

1.0.29

4 months ago

1.0.28

7 months ago

1.0.27

9 months ago

1.0.26

11 months ago

1.0.19

12 months ago

1.0.18

12 months ago

1.0.17

12 months ago

1.0.16

12 months ago

1.0.22

12 months ago

1.0.21

12 months ago

1.0.20

12 months ago

1.0.25

11 months ago

1.0.24

11 months ago

1.0.23

12 months ago

1.0.15

12 months ago

1.0.14

12 months ago

1.0.13

12 months ago

1.0.12

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.2.38

2 years ago

0.2.37

2 years ago

0.2.36

2 years ago

0.2.35

2 years ago

0.2.34

2 years ago

0.2.33

2 years ago

0.2.32

2 years ago

0.2.31

2 years ago

0.2.30

2 years ago

0.2.29

2 years ago

0.2.28

2 years ago

0.2.27

2 years ago

0.2.26

3 years ago

0.2.25

3 years ago

0.2.24

3 years ago

0.2.23

3 years ago

0.2.22

3 years ago

0.2.21

3 years ago

0.2.20

3 years ago

0.2.19

3 years ago

0.2.18

3 years ago

0.2.17

3 years ago

0.2.16

3 years ago

0.2.15

3 years ago

0.2.14

3 years ago

0.2.13

4 years ago

0.2.12

4 years ago

0.2.11

4 years ago

0.2.10

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.1

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.0

4 years ago

0.1.10

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.9

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago