1
votes

I use plugin Ext.ux.form.DateTimeField for Extjs and standart Ext.form.field.Date to edit defferent cells in grid according to special parameters in other column. Here is an example:

var myOwnGrid = {
    xtype: 'gridpanel',
    store: myOwnStore,
    ...
    columns: [
        {xtype: 'gridcolumn',
        dataIndex: 'mainParamValues',
        text: 'MyValues',
        ...
        getEditor: function(record){
            switch(record.raw.mainParamNames){ //accourding to value from other column
                case "date":
                    return Ext.create('Ext.grid.CellEditor', {
                        field: Ext.create('Ext.form.field.Date', {
                            value: record.raw.mainParamValues,
                            format: 'Ymd',
                            altFormats: 'Ymd',
                            emptyText: "Empty field!"
                        })
                    });
                }
            }
        }]
    }

When I press on cell and edit, it has correct format for me (20141212 for example). After I press enter or produce other action to save this value, it is automatically formated to "Fri Dec 12 2014 00:00:00 GMT+0300 (MSK)". I have to use these data after editing of full form, so I need 'Ymd' format. Any ideas how to fix such behaviour?

1

1 Answers

1
votes

You do not specify default renderer for this field type

{
    xtype: 'gridcolumn',
    dataIndex: 'mainParamValues',
    text: 'MyValues',
    ...
    renderer: Ext.Function.bind(renderCell, this)
}

...

function renderCell(val, meta, rec, rowIndex, colIndex) {
    var mainParamNames = 'date'; // your code by record

    switch (mainParamNames) {
    case "date":
        return Ext.util.Format.date(val, 'Y.m.d');
    }
}

Fiddle