gregnb / gregnb/mui-datatables

Is there a way to display total amount in a format with thousand digits without changing the data type (number) of the total amount

Open
#1,890 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.7k
Forks
906
PR merge metrics
No merged PRs in 30d

Description

Is there a way where I could still display the total amount with the thousand digits without changing its data type?

## Expected Behavior

Display the total amount in a format with a thousand digits without it converting into a string. Formatting it like this:
` {totalAmount.toLocaleString(navigator.language, {
minimumFractionDigits: 2,
})}`

## Current Behavior

If I use the `customBodyRender` to format it like this ` {value.toLocaleString(navigator.language, {
minimumFractionDigits: 2,
})}` this will return a string, hence, I would not be able to calculate the sum of all the total amount. Is there a way where I could still display it with a thousand digits without affecting the original value of the total amount?

## Steps to Reproduce (for bugs)

https://codesandbox.io/s/xenodochial-fog-s984v0?file=/src/App.js

## Your Environment

| Tech | Version |
|--------------|---------|
| Material-UI | 5.5.0 |
| MUI-datatables | 4.1.2 |
| React | 17.0.2 |
| browser | Google Chrome |
| etc | |

Contributor guide

No contributing guide indexed for this repository

Research direction

Open the linked CodeSandbox and inspect src/App.js, especially the column's customBodyRender usage and the total calculation. Then trace the corresponding rendering and aggregation entry points in the repository. Done should mean the amount displays with thousands separators while the value used for summing remains numeric, with the behavior demonstrated by a test or reproducible example.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.