ivryan
March 29, 2022, 10:38am
#1
@PablocFonseca can you show how format a Datetime in a AgGrid.
I’ve tried unsuccessfully to use valueFormatter as shown below:
gb.configure_column("date_column", header_name="Activation Date",valueFormatter="data.date_column.toLocaleDateString('it-IT',{ weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })", editable=False)
Could you help me please?
cualr
March 30, 2022, 12:07am
#2
Since AgGrid uses pandas, it seems that you could utilize pandas.to_datetime and something like --df[‘date_column_name’].dt.strftime(’%d-%m-%Y’) to format the date variable or to create another column with the desired format.
ivryan
March 30, 2022, 5:34am
#3
I know it’s feasible but it doesn’t meet my need.
I want to use dates an filter them using calendar widget
cualr
April 4, 2022, 1:27pm
#4
This may be a functionality question for @PablocFonseca .
ivryan
April 7, 2022, 7:18am
#5
@PablocFonseca can you halp me on this topic?
Thanks
You’ll need to use valueFormatter in column definition. Check JavaScript Data Grid: Cell Expressions .
Using the gridBuilder you could try something like, I’ve coded some helpful comlumn types:
gb.configure_column("date_column", type=["customDateTimeFormat"], custom_format_string='yyyy-MM-dd HH:mm zzz')
Let me know if it works
1 Like
ivryan
April 7, 2022, 10:57pm
#7
Thank you @PablocFonseca it works
Yike_Ma
December 6, 2022, 8:22am
#8
Hi @PablocFonseca . Is there a way to format multiple date columns in one go? now have to write the code for every single date column