Skip to content

Commit

Permalink
Merge pull request #1345 from gregnb/v3_1_0
Browse files Browse the repository at this point in the history
mui-datatables version 3.1.0
  • Loading branch information
patorjk authored Jun 22, 2020
2 parents 07427cd + 04b50b8 commit 9ac127d
Show file tree
Hide file tree
Showing 32 changed files with 1,406 additions and 668 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ The component accepts the following props:
|:--:|:-----|:-----|
|**`title`**|array|Title used to caption table
|**`columns`**|array|Columns used to describe table. Must be either an array of simple strings or objects describing a column
|**`data`**|array|Data used to describe table. Must be either an array containing objects of key/value pairs with values that are strings or numbers, or arrays of strings or numbers (Ex: data: [{"Name": "Joe", "Job Title": "Plumber", "Age": 30}, {"Name": "Jane", "Job Title": "Electrician", "Age": 45}] or data: [["Joe", "Plumber", 30], ["Jane", "Electrician", 45]])
|**`data`**|array|Data used to describe table. Must be either an array containing objects of key/value pairs with values that are strings or numbers, or arrays of strings or numbers (Ex: data: [{"Name": "Joe", "Job Title": "Plumber", "Age": 30}, {"Name": "Jane", "Job Title": "Electrician", "Age": 45}] or data: [["Joe", "Plumber", 30], ["Jane", "Electrician", 45]]). The **customBodyRender** and **customBodyRenderLite** options can be used to control the data diaplay.
|**`options`**|object|Options used to describe table
|**`components`**|object|Custom components used to render the table

Expand All @@ -154,6 +154,7 @@ The component accepts the following props:
|:--:|:-----|:--|:-----|
|**`caseSensitive `**|boolean|false|Enable/disable case sensitivity for search.
|**`confirmFilters`**|boolean|false|Works in conjunction with the **customFilterDialogFooter** option and makes it so filters have to be confirmed before being applied to the table. When this option is true, the customFilterDialogFooter callback will receive an applyFilters function which, when called, will apply the filters to the table. [Example](https://github.com/gregnb/mui-datatables/blob/master/examples/serverside-filters/index.js)
|**`columnOrder`**|array||An array of numbers (column indices) indicating the order the columns should be displayed in. Defaults to the order provided by the Columns prop. This option is useful if you'd like certain columns to swap positions (see draggableColumns option).
|**`count`**|number||User provided override for total number of rows.
|**`customFilterDialogFooter `**|function||Add a custom footer to the filter dialog. `customFilterDialogFooter(curentFilterList: array, applyFilters: function) => React Component`
|**`customFooter`**|function||Render a custom table footer. `function(count, page, rowsPerPage, changeRowsPerPage, changePage, `[`textLabels: object`](https://github.com/gregnb/mui-datatables/blob/master/src/textLabels.js)`) => string`|` React Component` [Example](https://github.com/gregnb/mui-datatables/blob/master/examples/customize-footer/index.js)
Expand All @@ -165,8 +166,9 @@ The component accepts the following props:
|**`customToolbar`**|function||Render a custom toolbar
|**`customToolbarSelect`**|function||Render a custom selected rows toolbar. `function(selectedRows, displayData, setSelectedRows) => void`
|**`download`**|boolean|true|Show/hide download icon from toolbar
|**`downloadOptions`**|object|`{filename: 'tableDownload.csv', separator: ','}`|Options to change the output of the CSV file: `filename`: string, `separator`: string, `filterOptions`: object(`useDisplayedColumnsOnly`: boolean, `useDisplayedRowsOnly`: boolean)
|**`elevation`**|number|4|Shadow depth applied to Paper component.
|**`downloadOptions`**|object|`{filename: 'tableDownload.csv', separator: ','}`|An object of options to change the output of the CSV file:<p><ul><li>`filename`: string</li><li>`separator`: string</li><li>`filterOptions`: object<ul><li>`useDisplayedColumnsOnly`: boolean</li><li>`useDisplayedRowsOnly`: boolean</li></ul></li></ul></p>
|**`draggableColumns`**|object|{}|An object of options describing how dragging columns should work. The options are: <p><ul><li>`enabled:boolean`: Indicates if draggable columns are enabled. Defaults to false.</li><li>`transitionTime:number`: The time in milliseconds it takes for columns to swap positions. Defaults to 300.</li></ul></p>To disable the dragging of a particular column, see the "draggable" option in the columns options. Dragging a column to a new position updates the columnOrder array and triggers the onColumnOrderChange callback.
|**`elevation`**|number|4|Shadow depth applied to Paper component.
|**`enableNestedDataAccess`**|string|""|If provided a non-empty string (ex: "."), it will use that value in the column's names to access nested data. For example, given a enableNestedDataAccess value of "." and a column name of "phone.cell", the column would use the value found in `phone:{cell:"555-5555"}`. Any amount of nesting will work. [Example](https://github.com/gregnb/mui-datatables/blob/master/examples/data-as-objects/index.js) demonstrates the functionality.
|**`expandableRows`**|boolean|false|Enable/disable expandable rows.
|**`expandableRowsHeader`**|boolean|true|Show/hide the expand all/collapse all row header for expandable rows.
Expand All @@ -180,9 +182,11 @@ The component accepts the following props:
|**`onCellClick`**|function||Callback function that triggers when a cell is clicked. `function(colData: any, cellMeta: { colIndex: number, rowIndex: number, dataIndex: number }) => void`
|**`onChangePage`**|function||Callback function that triggers when a page has changed. `function(currentPage: number) => void`
|**`onChangeRowsPerPage`**|function||Callback function that triggers when the number of rows per page has changed. `function(numberOfRows: number) => void`
|**`onColumnOrderChange`**|function||Callback function that triggers when a column has been dragged to a new location. `function(newColumnOrder:array, columnIndex:number, newPosition:number) => void`
|**`onColumnSortChange`**|function||Callback function that triggers when a column has been sorted. `function(changedColumn: string, direction: string) => void`
|**`onDownload`**|function||A callback function that triggers when the user downloads the CSV file. In the callback, you can control what is written to the CSV file. This method can be used to add the Excel specific BOM character (see this [example](https://github.com/gregnb/mui-datatables/pull/722#issuecomment-526346440)). `function(buildHead: (columns) => string, buildBody: (data) => string, columns, data) => string`. Return `false` to cancel download of file.
|**`onFilterChange`**|function||Callback function that triggers when filters have changed. `function(changedColumn: string, filterList: array, type: enum('checkbox', 'dropdown', 'multiselect', 'textField', 'custom', 'chip', 'reset'), changedColumnIndex, displayData) => void`
|**`onFilterChipClose`**|function||Callback function that is triggered when a user clicks the "X" on a filter chip. `function(index : number, removedFilter : string, filterList : array) => void` [Example](https://github.com/gregnb/mui-datatables/blob/master/examples/serverside-filters/index.js)
|**`onFilterConfirm`**|function||Callback function that is triggered when a user presses the "confirm" button on the filter popover. This occurs only if you've set **confirmFilters** option to true. `function(filterList: array) => void` [Example](https://github.com/gregnb/mui-datatables/blob/master/examples/serverside-filters/index.js)
|**`onFilterDialogClose`**|function||Callback function that triggers when the filter dialog closes. `function() => void`
|**`onFilterDialogOpen`**|function||Callback function that triggers when the filter dialog opens. `function() => void`
Expand Down Expand Up @@ -256,15 +260,17 @@ const columns = [
#### Column Options:
|Name|Type|Default|Description
|:--:|:-----|:--|:-----|
|**`customBodyRender`**|function||Function that returns a string or React component. Used as display data within all table cells of a given column. `function(value, tableMeta, updateValue) => string`&#124;` React Component` [Example](https://github.com/gregnb/mui-datatables/blob/master/examples/component/index.js)
|**`customBodyRender`**|function||Function that returns a string or React component. Used to display data within all table cells of a given column. The value returned from this function will be used for filtering in the filter dialog. If this isn't need, you may want to consider customBodyRenderLite instead. `function(value, tableMeta, updateValue) => string`&#124;` React Component` [Example](https://github.com/gregnb/mui-datatables/blob/master/examples/component/index.js)
|**`customBodyRenderLite`**|function||Function that returns a string or React component. Used to display data within all table cells of a given column. This method performs better than customBodyRender but has the following caveats: <p><ul><li>The value returned from this function is **not** used for filtering, so the filter dialog will use the raw data from the data array.</li><li>This method only gives you the dataIndex and rowIndex, leaving you to lookup the column value.</li></ul></p>`function(dataIndex, rowIndex) => string`&#124;` React Component` [Example](https://github.com/gregnb/mui-datatables/blob/master/examples/large-data-set/index.js)
|**`customFilterListOptions`**|{render: function, update: function}|| (These options only affect the filter chips that display after filters are selected. To modify the filters themselves, see `filterOptions`) `render` returns a string or array of strings used as the chip label(s). `function(value) => string OR arrayOfStrings`, `update` returns a `filterList (see above)` allowing for custom filter updates when removing the filter chip [Example](https://github.com/gregnb/mui-datatables/blob/master/examples/column-filters/index.js)
|**`customHeadRender`**|function||Function that returns a string or React component. Used as display for column header. `function(columnMeta, handleToggleColumn, sortOrder) => string`&#124;` React Component`
|**`display`**|string|'true'|Display column in table. `enum('true', 'false', 'excluded')`
|**`download`**|boolean|true|Display column in CSV download file.
|**`draggable`**|boolean|true|Determines if a column can be dragged. The draggableColumns.enabled option must also be true.
|**`empty`**|boolean|false|This denotes whether the column has data or not (for use with intentionally empty columns).
|**`filter`**|boolean|true|Display column in filter list.
|**`filterList`**|array||Filter value list [Example](https://github.com/gregnb/mui-datatables/blob/master/examples/column-filters/index.js)
|**`filterOptions`**|{names, logic, display(filterList, onChange(filterList, index, column), index, column, filterData), renderValue}||(These options affect the filter display and functionality from the filter dialog. To modify the filter chips that display after selecting filters, see `customFilterListOptions`) With filter options, it's possible to use custom names for the filter fields [Example](https://github.com/gregnb/mui-datatables/blob/master/examples/column-filters/index.js), custom filter logic [Example](https://github.com/gregnb/mui-datatables/blob/master/examples/customize-filter/index.js), and custom rendering [Example](https://github.com/gregnb/mui-datatables/blob/master/examples/customize-filter/index.js). `filterList` must be of the same type in the main column options, that is an array of arrays, where each array corresponds to the filter list for a given column.
|**`filterOptions`**|object||<p><i>These options affect the filter display and functionality from the filter dialog. To modify the filter chips that display after selecting filters, see `customFilterListOptions`</i></p><p>This option is an object of several options for customizing the filter display and how filtering works.</p><p><ul><li>names: custom names for the filter fields [Example](https://github.com/gregnb/mui-datatables/blob/master/examples/column-filters/index.js)</li><li>logic: custom filter logic [Example](https://github.com/gregnb/mui-datatables/blob/master/examples/customize-filter/index.js)</li><li>display(filterList, onChange(filterList, index, column), index, column, filterData): Custom rendering inside the filter dialog [Example](https://github.com/gregnb/mui-datatables/blob/master/examples/customize-filter/index.js). `filterList` must be of the same type in the main column options, that is an array of arrays, where each array corresponds to the filter list for a given column.</li><li>renderValue: A function to customize filter choices [Example](https://github.com/gregnb/mui-datatables/blob/master/examples/customize-filter/index.js). Example use case: changing empty strings to "(empty)" in a dropdown.</li><li>fullWidth (boolean): Will force a filter option to take up the grid's full width.</li></ul></p>
|**`filterType `**|string|'dropdown'|Choice of filtering view. Takes priority over global filterType option.`enum('checkbox', 'dropdown', 'multiselect', 'textField', 'custom')` Use 'custom' if you are supplying your own rendering via `filterOptions`.
|**`hint`**|string||Display hint icon with string as tooltip on hover.
|**`print`**|boolean|true|Display column when printing.
Expand Down
7 changes: 4 additions & 3 deletions examples/array-value-columns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ class Example extends React.Component {
options: {
filter: true,
filterType: 'multiselect',
customBodyRender: (value) => {
customBodyRenderLite: (dataIndex) => {
let value = data[dataIndex][5];
return value.map( (val, key) => {
return <Chip label={val} key={key} />;
});
}
},
}
}
},
];


Expand Down
5 changes: 2 additions & 3 deletions examples/column-filters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ class Example extends React.Component {
{
name: "Age",
options: {
customBodyRender: (val, tableMeta) => {
console.log(val);
console.dir(tableMeta);
customBodyRenderLite: (dataIndex) => {
let val = data[dataIndex][3];
return val;
},
filter: true,
Expand Down
7 changes: 5 additions & 2 deletions examples/column-options-update/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Example extends React.Component {
[],
[]
],
filterOptions: ['this', 'test', 'is', 'working'],
filterOptions: ['Franky Miles', 'this', 'test', 'is', 'working'],
display: ['true', 'true', 'true', 'true', 'true'],
data: [
["Gabby George", "Business Analyst", "Minneapolis", 30, 100000],
Expand Down Expand Up @@ -93,7 +93,10 @@ class Example extends React.Component {
name: "Location",
options: {
display: this.state.display[2],
filter: false,
filter: true,
filterOptions: {
fullWidth: true,
},
filterList: filterList[2].length ? filterList[2] : null,
}
},
Expand Down
5 changes: 4 additions & 1 deletion examples/csv-export/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ class Example extends React.Component {
{
name: 'Age',
options: {
customBodyRender: value => <div><span>{value}</span></div>
customBodyRenderLite: (dataIndex) => {
let value = data[dataIndex][3];
return <div><span>{value}</span></div>;
}
}
},
{
Expand Down
9 changes: 4 additions & 5 deletions examples/custom-action-columns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Example extends React.Component {
filter: false,
sort: false,
empty: true,
customBodyRender: (value, tableMeta, updateValue) => {
customBodyRenderLite: (dataIndex) => {
return (
<button onClick={() => {
const { data } = this.state;
Expand All @@ -69,9 +69,9 @@ class Example extends React.Component {
filter: false,
sort: false,
empty: true,
customBodyRender: (value, tableMeta, updateValue) => {
customBodyRenderLite: (dataIndex, rowIndex) => {
return (
<button onClick={() => window.alert(`Clicked "Edit" for row ${tableMeta.rowIndex}`)}>
<button onClick={() => window.alert(`Clicked "Edit" for row ${rowIndex} with dataIndex of ${dataIndex}`)}>
Edit
</button>
);
Expand Down Expand Up @@ -116,7 +116,7 @@ class Example extends React.Component {
filter: false,
sort: false,
empty: true,
customBodyRender: (value, tableMeta, updateValue) => {
customBodyRenderLite: (dataIndex) => {
return (
<button onClick={() => {
const { data } = this.state;
Expand Down Expand Up @@ -168,7 +168,6 @@ class Example extends React.Component {
filter: true,
filterType: 'dropdown',
responsive: 'vertical',
page: 2,
onColumnSortChange: (changedColumn, direction) => console.log('changedColumn: ', changedColumn, 'direction: ', direction),
onChangeRowsPerPage: numberOfRows => console.log('numberOfRows: ', numberOfRows),
onChangePage: currentPage => console.log('currentPage: ', currentPage)
Expand Down
7 changes: 7 additions & 0 deletions examples/custom-components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,18 @@ class Example extends React.Component {
['James Houston', 'Test Corp', 'Dallas', 'TX'],
];

let options = {
onFilterChipClose: (index, removedFilter, filterList) => {
console.log(index, removedFilter, filterList);
}
};

return (
<MUIDataTable
title={"ACME Employee list"}
data={data}
columns={columns}
options={options}
components={{
TableFilterList: CustomFilterList,
Tooltip: CustomTooltip,
Expand Down
Loading

0 comments on commit 9ac127d

Please sign in to comment.