1. #1
    Sencha User gskluzacek's Avatar
    Join Date
    Feb 2010
    Location
    Algonquin, IL
    Posts
    63
    Vote Rating
    3
    gskluzacek is on a distinguished road

      0  

    Question date strings not processed correctly in JsonReader's realize() & update() methods

    date strings not processed correctly in JsonReader's realize() & update() methods


    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:

    Code:
    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:

    Code:
    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'
    					}
    					...
    				]
    			},
    			...
    		];
    		LocMaintWindowUi.superclass.initComponent.call(this);
    	}
    });

    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...


    Code:
    				this.loc_maint_form.getForm().submit({
    					url:'locations/location.php',
    					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)
    						}
    						selModel.selectRow(dsLoc.indexOf(selRec));
    						
    					},
    					...
    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
    -- Once you go Mac, you never go back!

  2. #2
    Sencha User gskluzacek's Avatar
    Join Date
    Feb 2010
    Location
    Algonquin, IL
    Posts
    63
    Vote Rating
    3
    gskluzacek is on a distinguished road

      0  

    Default


    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.

    Code:
    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?
    Last edited by gskluzacek; 24 Nov 2010 at 12:54 PM. Reason: remove color tags as they did not apply propperly
    -- Once you go Mac, you never go back!

Similar Threads

  1. [CLOSED][3.0.2] DataReader realize/update issues
    By kveeiv in forum Ext 3.x: Bugs
    Replies: 4
    Last Post: 8 Dec 2009, 10:48 AM
  2. Replies: 8
    Last Post: 13 May 2009, 12:41 PM
  3. JsonReader doesn't seem to handle none strings
    By tamsler in forum Ext GWT: Help & Discussion (1.x)
    Replies: 3
    Last Post: 5 Feb 2009, 11:26 PM
  4. Update Element to show current time & date
    By bin4ry in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 15 Sep 2008, 3:34 AM
  5. Make Date.parseDate accept an array of possible format strings
    By corey.gilmore in forum Community Discussion
    Replies: 2
    Last Post: 30 May 2007, 5:51 PM

Tags for this Thread