/* eslint react/prop-types: 0 */ /* eslint no-unused-vars: 0 */ import React from 'react'; import BootstrapTable from 'react-bootstrap-table-next'; import ToolkitProvider, { Search } from 'react-bootstrap-table2-toolkit'; import Code from 'components/common/code-block'; import { productsGenerator } from 'utils/common'; const { SearchBar } = Search; const products = productsGenerator(); const columns = [{ dataField: 'id', text: 'Product ID' }, { dataField: 'name', text: 'Product Name' }, { dataField: 'price', text: 'Product Price' }]; const sourceCode = `\ import BootstrapTable from 'react-bootstrap-table-next'; import ToolkitProvider, { Search } from 'react-bootstrap-table2-toolkit'; const { SearchBar } = Search; const columns = [{ dataField: 'id', text: 'Product ID' }, { dataField: 'name', text: 'Product Name' }, { dataField: 'price', text: 'Product Price' }]; // Implement startWith instead of contain function customMatchFunc({ searchText, value, column, row }) { if (typeof value !== 'undefined') { return value.startsWith(searchText); } return false; } export default () => (
{ props => (

Input something at below input field:


) }
{ sourceCode }
); `; // Implement startWith instead of contain function customMatchFunc({ searchText, value, column, row }) { if (typeof value !== 'undefined') { return `${value}`.toLowerCase().startsWith(searchText.toLowerCase()); } return false; } export default () => (

Custom a search match function by startWith instead of contain

{ props => (

Input something at below input field:


) }
{ sourceCode }
);