View Full Version : date strings not processed correctly in JsonReader's realize() & update() methods

22 Nov 2010, 12:33 PM
I have a JSON store that is configured with a field with a type of 'date' and dateFormat set to 'Y-m-d H:i:s' (mysql date format) defined as follows:

dsLocation = Ext.extend(Ext.data.JsonStore, {
constructor: function(cfg) {
cfg = cfg || {};
dsLocation.superclass.constructor.call(this, Ext.apply({
storeId: 'dsLocation',
root: 'rows',
url: 'locations/grid_locations.php',
idProperty: 'loc_id',
messageProperty: 'user_message',
totalProperty: 'results',
autoLoad: true,
remoteSort: true,
fields: [
name: 'updt_dt',
type: 'date',
dateFormat: 'Y-m-d H:i:s'

}, cfg));

I also have a grid configured to use the store with a date column as defined as follows:

LocMaintWindowUi = Ext.extend(Ext.Window, {
title: 'Location Maintenance',
width: 1015,
height: 690,
layout: 'border',
initComponent: function() {
this.items = [
xtype: 'grid',
store: 'dsLocation',
region: 'north',
height: 206,
margins: '5px 5px 0px 5px',
split: true,
closable: true,
autoExpandColumn: 'name',
ref: 'loc_maint_grid',
id: 'loc_maint_grid',
selModel: new Ext.grid.RowSelectionModel({
singleSelect: true
columns: [
xtype: 'datecolumn',
header: 'Update',
sortable: true,
width: 115,
dataIndex: 'updt_dt',
format: 'm/d/Y h:i a'

When the grid gets the loaded from the store, the date columns look fine, but after calling the form's submit action to update an existing record or insert a new record and then calling JsonReader.update(...) or JsonReader.realize(...), the date column for that record displays a bunch of not a number values...

params: {crud_action: crudAction},
waitMsg:'Processing Data...',

success: function (form, action) {

var grid = form.ownerCt.loc_maint_grid; // get the gridPanel
var selModel = grid.getSelectionModel(); // get the selection model
var dsLoc = grid.getStore(); // get the data store
var selRec = selModel.getSelected(); // get the selected record

if (crudAction == 'INSERT') {
dsLoc.reader.realize(selRec, action.result.rows)
} else {
dsLoc.reader.update(selRec, action.result.rows)


The data returned from the form's submit action and being passed into update()/realize() is in the same format as the data returned from the initial grid load...

Guess I'm wondering why the reader is not converting the date field's data from incoming 'Y-m-d H:i:s' format to a native JavaScript Date object for update()/realize() like it does on the initial grid load().

Is there a something that I missed in my configuration (using Ext JS Designer)?

You can see the application here http://ccbdb.com/xds_index.html

Thanks and Regards,
-- Greg

24 Nov 2010, 12:52 PM
Adding the following 2 lines of code before the if (curdAction == 'INSERT') { seems to have solved my problem, but I question if this is a bug, as I would think any convert functions or dateFormat specifications on the data store's field would be applied when realize() and update() are called, as the DataReader has access to the field definitions.

action.result.rows.crt_dt = new Date(action.result.rows.crt_dt);
action.result.rows.updt_dt = new Date(action.result.rows.updt_dt);

Should this be considered a bug that needs to be written up?