-
Notifications
You must be signed in to change notification settings - Fork 782
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
base: master
Are you sure you want to change the base?
Conversation
HI @bradleysmagacz so this default value will be apply on every columns when |
Hi @AllenFang, this will actually only apply at object key level. For example, lets say I have an array of objects that look like this:
And let's say the user passes in 'No Data' as the defaultValue prop. When the table renders, Greg's weight will be set to 'No Data' instead of an empty field. If the user does not pass in a defaultValue prop, everything will function as before. Although it's not a common use case, there are situations in our application where we need to render a default value when the object key does not exist or no data is available. |
@bradleysmagacz, I see, thanks your descriptions 👍 |
HI @bradleysmagacz , after review, I think the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @AllenFang. How can the defaultValue prop be passed down to |
If I may add something: I'd rather have the default value be a PropTypes.func than a PropTypes.string, so that we can make it work nicely if sorting or filtering is invoked (the value for a cell may be a Date or a number.) |
Also: don't you want this default value to be proposed (by default) in the Add Row dialog? (This is what I would understand of a column's default value.) |
Let me know if you still have any questions, thanks |
In some cases, the user may want to display a default value in the table if no data is available instead of a blank value. The user can add a 'defaultValue' prop to the BootstrapTable component if need be.