Hi all. Apologies if this is a stupid question/request, but I’m a bit of a noob. However, I’ve been searching for the last couple of weeks for a way to be able to format figures in tables I’m making with the st_aggrid library/component, to have comma delimiters for thousands, millions, etc.
While I’ve found a number of references to the valueFormatter, in each instance that appears to be formatting a specific data column (eg valueFormatter="parseFloat(data.numeric_column_a)... where I believe numeric_column_a is a specific column name.)
I’ve created a function (which I called table_maker ) to build tables and into that function I pass a list of currency columns, using your customCurrencyFormat method, which is great. However, within this I’d like to add in the comma delimiters for thousands.
Does anyone know if there’s a way I can deploy the valueFormatter within the configure_columns method to achieve this result? Here’s what I’m using in my table_maker function to format the currency columns:
Again, apologies if this is not the right forum or I’m not being clear in the question. It’s just that I’ve been trying to get this working for a couple of weeks and can’t see any other way to move forward.
Assuming I have a CSV file containing the following fields (and 1 line of data)
EMPNAME,AMT
P. KUMAR,441270
You want to display the number as … say… $441,270.0 in the AGGRID display, right?
Then you can use something like this to configure your number column (in my case - a column named ‘AMT’:
I was hoping that there was a way to do this using the configure_columns method, as that’s what I’ve used to pass a list of columns in. I guess it may be possible to use a list comprehension through valueGetter or valueFormatter, but I was hoping there was a slick way I was missing within configure_columns that might avoid that.
Are you aware of some documentation that describes the different functions and parameters, like the ones you have used here for gb.configure_column in detail? The official documentation I found here, does not have these details.
I want to display a number with commas (1,200 instead of 1200), without a decimal. I am not able to figure out how to do that with gb.configure_column
Hi @mjo, to answer your question - No, I don’t have access to any special documentation on AGgrid. I learn by the trials of others and my own. Good places to know details about AGgrid are:
a. This forum - just search aggrid and you will get a lot of info and code that you can try out and repurpose.
b. Pablo’s - the creator’s - GitHub, for docs and examples
c The AG grid website
d And finally, Google
Below are some configure column (numeric column) examples, that are easily understandable, that you can reference for information:
a. gb.configure_column("Amt", header_name=("Amount"), editable=True, type=["numericColumn","numberColumnFilter","customNumericFormat"], precision=0)
b. gb.configure_column('MySum', type=['numericColumn'], valueGetter='(Number(data.EMPLVL) * 5.23).toFixed(1)', editable='false', resizable=False, sortable=False)
Regarding your comma number formatting, you could try out the valueGetter or through JScode. If I get some time this weekend, I will try to check that out for you.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.