Our blazing fast Grid component built with pure JavaScript


Post by gregc »

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

,"startdate": "2021-01-09T14:15:00Z","enddate": "2021-01-12T08:00:00Z"

I can put a YYYY-MM-DD format on a column and it formats fine
e.g.

{ field: 'startdate', format : 'YYYY-MM-DD', editor : 'datetimefield' , type: 'startdate' },

But if I try to change it to DD-MMM-YYYY it blows up

{ field: 'enddate', format: 'DD-MM-YYYY', editor : 'datetimefield',  type: 'enddate' },

and displays incorrect dates
e.g. see finish column

Last edited by gregc on Tue Feb 23, 2021 12:33 am, edited 2 times in total.

Post by mats »

Looks like a bug yes, we'll look into it https://github.com/bryntum/support/issues/2427


Post by mats »

Spoke too soon, it's since you have not defined your Model field correctly. Add a field which defines it as a date and all should work fine.

new Grid({
    appendTo : 'container',
    store    : {
        fields : [
            { name : 'start', type : 'date' }
        ]
    },
    columns : [
        { text : 'Date', field : 'start', flex : 1, type : 'date', format : 'DD-MM-YYYY' }
    ],

data : [
    { start : '2021-01-09T14:15:00Z' }
]
});


Post by gregc »

This is the Gantt chart, it is the type of 'startdate' and that is predefined right?

Last edited by gregc on Mon Feb 22, 2021 3:10 pm, edited 1 time in total.

Post by mats »

No, you are pointing to some field 'startdate' which we don't have. Our standard fields are 'startDate', 'endDate', etc - you can read all about it in our docs:

https://bryntum.com/docs/gantt/#Gantt/model/TaskModel#fields


Post by gregc »

Ah my bad, I should have tested my date formats on a working example, not that old demo, thanks !


Post by mats »

Most welcome! :)


Post by gregc »

Is there a path of least resistance to get a datetime column added to a regular grid, without importing all the Gantt stuff?


Post by mats »

Not sure what you mean, you just

import 'Grid/column/DateColumn.js';

Post by gregc »

The regular default 'date' column type doesn't have a getTime method and so doesn't work with the datetimefield editor.


Post Reply