Format Date Time in AgGrid

@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?

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.

1 Like

I know it’s feasible but it doesn’t meet my need.

I want to use dates an filter them using calendar widget

This may be a functionality question for @PablocFonseca.

@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

3 Likes

Thank you @PablocFonseca it works

1 Like

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

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.