mui-datatables - Add missing types for arguments of customToolbarSelect (#33836)

* Add types for custom selected toolbar args

* Fix lint errors

* remove whitespaces
This commit is contained in:
Ankith Konda 2019-03-14 07:48:40 +10:00 committed by Wesley Wigham
parent 70fbf57f7b
commit 569a9c76fd
2 changed files with 24 additions and 1 deletions

View File

@ -1,6 +1,7 @@
// Type definitions for mui-datatables 2.0
// Project: https://github.com/gregnb/mui-datatables
// Definitions by: Jeroen "Favna" Claassens <https://github.com/favna>
// Ankith Konda <https://github.com/ankithkonda>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@ -122,7 +123,14 @@ export interface MUIDataTableOptions {
expandableRows?: boolean;
renderExpandableRow?: (rowData: string[], rowMeta: { dataIndex: number; rowIndex: number }) => React.ReactNode;
customToolbar?: () => React.ReactNode;
customToolbarSelect?: () => React.ReactNode;
customToolbarSelect?: (
selectedRows: {
data: Array<{ index: number; dataIndex: number }>;
lookup: { [key: number]: boolean };
},
displayData: Array<{ data: any[]; dataIndex: number }>,
setSelectedRows: (rows: number[]) => void
) => React.ReactNode;
customFooter?: () => React.ReactNode;
customSort?: (data: any[], colIndex: number, order: string) => any[];
elevation?: number;

View File

@ -25,6 +25,21 @@ class MuiCustomTable extends React.Component<Props> {
separator: ','
},
sortFilterList: false,
customToolbarSelect: (selectedRows, displayData, setSelectedRows) => {
return (
<span>
Custom Selected Toolbar:{' '}
{`${selectedRows.data.length} - ${JSON.stringify(displayData[0])}`}
<button
onClick={() => {
setSelectedRows([]);
}}
>
Set Selected Row to none
</button>
</span>
);
},
textLabels: {
body: {
noMatch: 'Sorry, no matching records found',