0
votes

I have a grid that for a cell I use a TimeField editor:

{
    text: 'InTime',
    dataIndex: 'InTime',
    editor: {
        xtype: 'timefield',
        format: 'H:i', // 24 hour format
        altFormats: 'H:i', // 24 hour format
        selectOnFocus: true,
        minValue: '12:00 AM',
        increment: 60,
        maxValue: '11:00 PM'
    }

My cells looks like this before and on editing:

enter image description here

At this point everything works fine, when I open the dropdown also everything looks fine:

enter image description here

But after I select a value from the list and change to other cell, then the value updated in the cell is a datetime string format text, like this:

enter image description here

Does anyone knows why is happening this?

Thanks

2
You always have to specify a renderer, otherwise the toString of your data value is used. The grid does not magically render it like the editor (combo). Just as if you had a regular combo box drop down. See stackoverflow.com/questions/5900294/extjs-grid-combo-box-issue/…Juan Mendes

2 Answers

1
votes

Use format format:'g:i A', in editor renderer: Ext.util.Format.dateRenderer('g:i A') in grid cell field

{
text: 'InTime',
renderer: Ext.util.Format.dateRenderer('g:i A')
dataIndex: 'InTime',
editor: {
    xtype: 'timefield',
    format: 'H:i', // 24 hour format
    altFormats: 'H:i', // 24 hour format
    selectOnFocus: true,
    minValue: '12:00 AM',
    increment: 60,
    maxValue: '11:00 PM'
}

That is because you always have to specify a renderer, otherwise the toString of your data value (the Date) is used. The grid does not magically render it like the editor (combo).

0
votes

Apart from what I left on your other post about H:i being a 24 hours format. Get your field value with field.getRawValue() instead of getValue() if you want the formatted string.