mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
a workaround for fixing the _ module missing
This commit is contained in:
parent
ec77a0539d
commit
fadbcdaa24
@ -40,18 +40,33 @@ class ToolkitProvider extends statelessDrcorator(React.Component) {
|
||||
this.state = {
|
||||
searchText: ''
|
||||
};
|
||||
this._ = null;
|
||||
this.onSearch = this.onSearch.bind(this);
|
||||
this.setDependencyModules = this.setDependencyModules.bind(this);
|
||||
}
|
||||
|
||||
onSearch(searchText) {
|
||||
this.setState({ searchText });
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} _
|
||||
* this function will be called only one time when table render
|
||||
* react-bootstrap-table-next/src/context/index.js will call this cb for passing the _ module
|
||||
* Please consider to extract a common module to handle _ module.
|
||||
* this is just a quick fix
|
||||
*/
|
||||
setDependencyModules(_) {
|
||||
this._ = _;
|
||||
}
|
||||
|
||||
render() {
|
||||
const baseProps = {
|
||||
keyField: this.props.keyField,
|
||||
columns: this.props.columns,
|
||||
data: this.props.data
|
||||
data: this.props.data,
|
||||
setDependencyModules: this.setDependencyModules
|
||||
};
|
||||
if (this.props.search) {
|
||||
baseProps.search = {
|
||||
|
||||
@ -19,6 +19,7 @@ export const getMetaInfo = columns =>
|
||||
export const transform = (
|
||||
data,
|
||||
meta,
|
||||
getValue,
|
||||
{
|
||||
separator,
|
||||
ignoreHeader
|
||||
@ -36,7 +37,7 @@ export const transform = (
|
||||
content += data
|
||||
.map((row, rowIndex) =>
|
||||
visibleColumns.map((m) => {
|
||||
let cellContent = row[m.field];
|
||||
let cellContent = getValue(row, m.field);
|
||||
if (m.formatter) {
|
||||
cellContent = m.formatter(cellContent, row, rowIndex, m.formatExtraData);
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ export default Base =>
|
||||
...csvDefaultOptions,
|
||||
...exportCSV
|
||||
};
|
||||
const content = transform(data, meta, options);
|
||||
const content = transform(data, meta, this._.get, options);
|
||||
save(content, options);
|
||||
}
|
||||
};
|
||||
|
||||
@ -179,7 +179,8 @@ BootstrapTable.propTypes = {
|
||||
search: PropTypes.shape({
|
||||
searchText: PropTypes.string,
|
||||
searchContext: PropTypes.func
|
||||
})
|
||||
}),
|
||||
setDependencyModules: PropTypes.func
|
||||
};
|
||||
|
||||
BootstrapTable.defaultProps = {
|
||||
|
||||
@ -47,6 +47,10 @@ const withContext = Base =>
|
||||
this.SearchContext = props.search.searchContext(
|
||||
_, this.isRemoteSearch, this.handleRemoteSearchChange);
|
||||
}
|
||||
|
||||
if (props.setDependencyModules) {
|
||||
props.setDependencyModules(_);
|
||||
}
|
||||
}
|
||||
|
||||
renderBase() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user