Our blazing fast Grid component built with pure JavaScript


Post by sachidanand »

My JSON date is coming in as UTC e.g.

I put a YYYY-MM-DD format on a column and it formats fine.
But when I change the format to DD-MM-YYYY, it breaks. I am trying to add the columns dynamically, here's the config:

{
		type = 'date';
                filterType = 'date';
                format = 'YYYY-MM-DD';
                rendererFunc = ({ record }: any) => {
                    const date: string = 2022-09-04T15:39:53.5924312+02:00; //Dummy data
                    return date ? DateHelper.format(new Date(date), 'DD.MM.YYYY') : '';
                };
        };

This code works fine i.e. when I try to edit the column, it shows the date in YYYY-MM-DD format, and in DD.MM.YYYY format otherwise.

Now, when i changed the format in column config above to DD.MM.YYYY or DD/MM/YYYY, the code breaks.
I want the format to remain constant i.e. (DD.MM.YYYY) in both the cases(while editing, and otherwise also)


Post by mats »

You should put 'format' on the column definition, then all will work fine. No need to use a renderer.


Post by sachidanand »

Renderer is needed to decide which field to show. Tried removing the pipe from the renderer, that also does not work.

The data shows fine, but when I try to edit it, it shows a totally different date.

Initially when the grid loads ,
END_DATE - 31.12.2022

When I double click the cell and edit mode opens, it shows : 01.01.1970 and a negative date in some scenarios.

Attaching the config again here:

{
            text: 'End Date',
            field: RANDOM_END_DATE,
            renderer: ({ record }: any) => {
                    const date: string = 2022-09-04T15:39:53.5924312+02:00; //Date fetching logic here
                    return date ? DateHelper.format(new Date(date), 'DD.MM.YYYY') : '';
                };
            type: 'date',
            align: 'center',
            sortable: true,
            hideable: true,
            hidden: false
            format: 'DD.MM.YYYY',
            width: 120
}

Post by tasnim »

Sorry, I've tried, but not able to reproduce. Could you please try if you can reproduce it in our online example here: https://bryntum.com/examples/grid/lockedcolumnstree/

If not reproducible could you please provide a runnable test case so we can investigate?


Post Reply