Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added prop defaultValue so users can display a default value for empty data #1487

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/BootstrapTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ class BootstrapTable extends Component {
tableBodyClass={ this.props.tableBodyClass }
style={ { ...style, ...this.props.bodyStyle } }
data={ this.state.data }
defaultValue={ this.props.defaultValue }
expandComponent={ this.props.expandComponent }
expandableRow={ this.props.expandableRow }
expandRowBgColor={ this.props.options.expandRowBgColor }
Expand Down Expand Up @@ -1426,6 +1427,7 @@ BootstrapTable.propTypes = {
height: PropTypes.oneOfType([ PropTypes.string, PropTypes.number ]),
maxHeight: PropTypes.oneOfType([ PropTypes.string, PropTypes.number ]),
data: PropTypes.oneOfType([ PropTypes.array, PropTypes.object ]),
defaultValue: PropTypes.string,
remote: PropTypes.oneOfType([ PropTypes.bool, PropTypes.func ]), // remote data, default is false
replace: PropTypes.oneOfType([ PropTypes.bool, PropTypes.func ]),
scrollTop: PropTypes.oneOfType([ PropTypes.string, PropTypes.number ]),
Expand Down
2 changes: 2 additions & 0 deletions src/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class TableBody extends Component {
} else {
columnTitle = column.columnTitle && fieldValue ? fieldValue.toString() : null;
}
if (!columnChild) { columnChild = this.props.defaultValue; }
return (
<TableColumn key={ i }
rIndex={ r }
Expand Down Expand Up @@ -500,6 +501,7 @@ class TableBody extends Component {
}
TableBody.propTypes = {
data: PropTypes.array,
defaultValue: PropTypes.string,
columns: PropTypes.array,
striped: PropTypes.bool,
bordered: PropTypes.bool,
Expand Down