I have tables rendered across multiple places with multiple data sources, implemented with react-bootstrap-table2.
For this, I have created one single component <MyTable ... />
which ultimately renders <BootstrapTable .../>
component.
Is there any way to apply a rule globally that if the whatever data being passed in has a blank value, a dash '-' should be rendered by default in that case?
Having formatter
applied on columns of each and every table is not a good idea.
You can write a common nullChecker
and use that for the column definitions where you might expect to have NO data.
You can still keep the common Bootstrap table
You will need to update the column definitions to add a
formatter
The
formatter
takes a reference to yournullChecker
and returns a value or a dash (-) based on if the value is present.
Have a look at this sandbox - https://codesandbox.io/embed/react-boot-table-defaultvalues-bpwgz
nullChecker
from helper.js
is used.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.