[react-bootstrap-table-next] add filter example

This commit is contained in:
Wlad Meixner
2020-03-15 19:59:13 +01:00
parent 0f6a139e70
commit d06faa3708
2 changed files with 44 additions and 1 deletions

View File

@@ -108,8 +108,9 @@ export type ColumnFormatter<R, E = any, C = any> = (
export type ColumnDescription<T = any, E = any> = (
| { isDummyField: true; dataField?: string; formatter?: ColumnFormatter<T, E, never> }
| { dataField: T[keyof T] | string; formatter?: ColumnFormatter<T, E, T[keyof T]> }
| { dataField: T[keyof T] | string }
) & {
formatter?: ColumnFormatter<T, E, any>;
hidden?: boolean;
/**
* Column header field

View File

@@ -83,6 +83,48 @@ render(
document.getElementById('app'),
);
/**
* Inline untyped columns test
*/
render(
<BootstrapTable
data={products}
bootstrap4
striped={true}
hover={true}
keyField="id"
columns={[
{ dataField: 'id', align: CellAlignment.center, sort: true, text: 'Product ID' },
{ dataField: 'name', align: CellAlignment.center, sort: true, text: 'Product Name' },
{
isDummyField: true,
dataField: '',
sort: true,
formatter: () => <span>Dummy Field</span>,
text: 'Dummy Columns',
},
{
dataField: 'price',
sort: true,
formatter: priceFormatter,
text: 'Product Price',
headerFormatter: priceHeaderFormatter,
},
/**
* test optional dataField for dummyFields
*/
{
isDummyField: true,
sort: true,
formatter: priceFormatter,
text: 'Product Price',
headerFormatter: priceHeaderFormatter,
},
]}
/>,
document.getElementById('app'),
);
/**
* Basic table with custom data indicator and caption
*/