I'm making a React app that has two view options:
- cards and
- lists (tables).
I'm using react-virtualized for the list-view option. The problem is that I need to change the format of the server-side data I get when the data type is number. I've already done that in the card-view option. For example, this is my ItemCard Component:
<div className="container">
<div>{id}</div>
<div>{name}</div>
<div>{parseFloat(inventory).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}</div>
<div>{parseFloat(unitprice).toFixed(2)}</div>
</div>
which I use in the ItemList Component like this:
beautifiedData.map((product, i) => {
return (
<ItemCard
key={i}
id={item.No}
name={item.name}
inventory={item.Inventory}
unitprice={item.UnitPrice}
/>
)
})
How should I do the exact same thing with react-virtualized table which looks like this:
<Table className="items-table"
width={1300}
height={400}
headerHeight={20}
rowHeight={30}
rowCount={list.length}
rowGetter={({ index }) => list[index]}
sortBy={this.state.sortBy}
sortDirection={this.state.sortDirection}
sort={this.sort}
>
<Column
label={content[langProp].ID}
dataKey= 'No'
width={150}
/>
<Column
label={content[langProp].Name}
dataKey= 'Name'
width={150}
/>
<Column
label={content[langProp].Inventory}
dataKey= 'Inventory'
width={150}
/>
<Column
label={content[langProp].UnitPrice}
dataKey= 'UnitPrice'
width={150}
/>
How can I change the format of 'Inventory' and 'UnitPrice' server-side data whose type is string?