mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2026-04-04 20:04:27 +00:00
allow to custom className on clear search and export csv button
This commit is contained in:
90
packages/react-bootstrap-table2-example/examples/bootstrap4/toolkits.js
vendored
Normal file
90
packages/react-bootstrap-table2-example/examples/bootstrap4/toolkits.js
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/* eslint react/prop-types: 0 */
|
||||
import React from 'react';
|
||||
|
||||
import BootstrapTable from 'react-bootstrap-table-next';
|
||||
import ToolkitProvider, { Search, CSVExport } from 'react-bootstrap-table2-toolkit';
|
||||
import Code from 'components/common/code-block';
|
||||
import { productsGenerator } from 'utils/common';
|
||||
|
||||
const { SearchBar, ClearSearchButton } = Search;
|
||||
const { ExportCSVButton } = CSVExport;
|
||||
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, CSVExport } from 'react-bootstrap-table2-toolkit';
|
||||
|
||||
const { SearchBar, ClearSearchButton } = Search;
|
||||
const { ExportCSVButton } = CSVExport;
|
||||
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'Product ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Product Name'
|
||||
}, {
|
||||
dataField: 'price',
|
||||
text: 'Product Price'
|
||||
}];
|
||||
|
||||
<ToolkitProvider
|
||||
keyField="id"
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
search
|
||||
>
|
||||
{
|
||||
props => (
|
||||
<div>
|
||||
<h3>Input something at below input field:</h3>
|
||||
<SearchBar { ...props.searchProps } />
|
||||
<ClearSearchButton { ...props.searchProps } />
|
||||
<hr />
|
||||
<BootstrapTable
|
||||
{ ...props.baseProps }
|
||||
/>
|
||||
<ExportCSVButton { ...props.csvProps }>Export CSV!!</ExportCSVButton>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</ToolkitProvider>
|
||||
`;
|
||||
|
||||
export default () => (
|
||||
<div>
|
||||
<ToolkitProvider
|
||||
keyField="id"
|
||||
data={ products }
|
||||
columns={ columns }
|
||||
search
|
||||
>
|
||||
{
|
||||
props => (
|
||||
<div>
|
||||
<h3>Input something at below input field:</h3>
|
||||
<SearchBar { ...props.searchProps } />
|
||||
<ClearSearchButton { ...props.searchProps } />
|
||||
<hr />
|
||||
<BootstrapTable
|
||||
{ ...props.baseProps }
|
||||
/>
|
||||
<ExportCSVButton { ...props.csvProps }>Export CSV!!</ExportCSVButton>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</ToolkitProvider>
|
||||
<Code>{ sourceCode }</Code>
|
||||
</div>
|
||||
);
|
||||
@@ -21,6 +21,7 @@ import Bootstrap4DefaultSortTable from 'examples/bootstrap4/sort';
|
||||
import Bootstrap4RowSelectionTable from 'examples/bootstrap4/row-selection';
|
||||
import Bootstrap4PaginationTable from 'examples/bootstrap4/pagination';
|
||||
import Bootstrap4ColumnToggleTable from 'examples/bootstrap4/column-toggle';
|
||||
import ToolkitsTable from 'examples/bootstrap4/toolkits';
|
||||
|
||||
// work on columns
|
||||
import NestedDataTable from 'examples/columns/nested-data-table';
|
||||
@@ -249,7 +250,8 @@ storiesOf('Bootstrap 4', module)
|
||||
.add('Sort table with bootstrap 4', () => <Bootstrap4DefaultSortTable />)
|
||||
.add('Row selection table with bootstrap 4', () => <Bootstrap4RowSelectionTable />)
|
||||
.add('Pagination table with bootstrap 4', () => <Bootstrap4PaginationTable />)
|
||||
.add('Column Toggle with bootstrap 4', () => <Bootstrap4ColumnToggleTable />);
|
||||
.add('Column Toggle with bootstrap 4', () => <Bootstrap4ColumnToggleTable />)
|
||||
.add('toolkits Table bootstrap 4', () => <ToolkitsTable />);
|
||||
|
||||
storiesOf('Work on Columns', module)
|
||||
.addDecorator(bootstrapStyle())
|
||||
|
||||
@@ -5,12 +5,14 @@ const ExportCSVButton = (props) => {
|
||||
const {
|
||||
onExport,
|
||||
children,
|
||||
className,
|
||||
...rest
|
||||
} = props;
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={ `react-bs-table-csv-btn btn btn-default ${className}` }
|
||||
onClick={ () => onExport() }
|
||||
{ ...rest }
|
||||
>
|
||||
@@ -26,7 +28,7 @@ ExportCSVButton.propTypes = {
|
||||
style: PropTypes.object
|
||||
};
|
||||
ExportCSVButton.defaultProps = {
|
||||
className: 'react-bs-table-csv-btn btn btn-default',
|
||||
className: '',
|
||||
style: {}
|
||||
};
|
||||
|
||||
|
||||
@@ -3,18 +3,21 @@ import PropTypes from 'prop-types';
|
||||
|
||||
const ClearButton = ({
|
||||
onClear,
|
||||
text
|
||||
text,
|
||||
className
|
||||
}) => (
|
||||
<button className="btn btn-default" onClick={ onClear }>{ text }</button>
|
||||
<button className={ `btn btn-default ${className}` } onClick={ onClear }>{ text }</button>
|
||||
);
|
||||
|
||||
ClearButton.propTypes = {
|
||||
onClear: PropTypes.func.isRequired,
|
||||
className: PropTypes.string,
|
||||
text: PropTypes.string
|
||||
};
|
||||
|
||||
ClearButton.defaultProps = {
|
||||
text: 'Clear'
|
||||
text: 'Clear',
|
||||
className: ''
|
||||
};
|
||||
|
||||
export default ClearButton;
|
||||
|
||||
Reference in New Issue
Block a user