import * as React from 'react'; import BootstrapTable, { CellAlignment, ColumnDescription, HeaderFormatter, ColumnFormatter, } from 'react-bootstrap-table-next'; import paginationFactory from 'react-bootstrap-table2-paginator'; import { render } from 'react-dom'; import ToolkitProvider, { InjectedSearchProps } from 'react-bootstrap-table2-toolkit'; interface Product { id: number; name: string; price?: number; quality?: number; inStockStatus?: number; sales?: number; } const products: Product[] = [ { id: 1, name: 'Item name 1', price: 100, }, { id: 2, name: 'Item name 2', price: 100, }, ]; const priceHeaderFormatter: HeaderFormatter = (column, colIndex, components) => { return (
{column.text} {components.sortElement} {components.filterElement}
); }; const priceFormatter: ColumnFormatter = (cell, row, rowIndex) => { return ( {rowIndex} - {cell} ); }; const productColumns: Array> = [ { dataField: 'id', align: 'center', sort: true, text: 'Product ID' }, { dataField: 'name', align: 'center', sort: true, text: 'Product Name' }, { isDummyField: true, dataField: '', sort: true, text: 'Product Name', }, { dataField: 'price', sort: true, formatter: priceFormatter, text: 'Product Price', headerFormatter: priceHeaderFormatter, }, /** * test optional dataField for dummyFields */ { isDummyField: true, dataField: '', sort: true, formatter: priceFormatter, text: 'Product Price', headerFormatter: priceHeaderFormatter, }, ]; /** * Toolkit with custom search test test */ const CustomSearch = (props: InjectedSearchProps) => { return ( props.onSearch(e.currentTarget.value)} /> ); }; render( {({ baseProps, searchProps }) => ( <> )} , document.getElementById('app'), );