PDA

View Full Version : Problem retrieving data in datefield



gigofizz
20 Dec 2011, 10:42 AM
I'm working on MVC and I have a problem retrieving the date in a datefield format(no return value).

MODEL
-----
services.js
fields: [{
name : 'stc_iid',
type : 'int'
},{
name : 'cue_lineaNombre'
//type : 'string'
},{
name : 'cue_cnombre'
},{
name : 'stc_dfecha_desde_1',
type : 'date', //
dateFormat : 'MS' // Convierte la fecha
}],




PHP
----
service.php


$row["stc_dfecha_hasta_1"]=$rs["stc_dfecha_hasta_1_format"]; // Devuelve "Date(-62135586000000-0300)" relativo




VIEW
--------
services.js
{
xtype: 'datefield',
name: 'stc_dfecha_desde_1',
fieldLabel: 'Fecha',
anchor: '100%',
width: 200
}
30194

friend
20 Dec 2011, 11:10 AM
Visit the API documentation for Ext.form.field.Date and see the section titled Date Formats Examples. In particular, you probably need to set the format attribute of your date field appropriately.

skirtle
20 Dec 2011, 5:53 PM
There are all sorts of places this could be going wrong.

The first thing I'd try is capturing the server response using Firebug or a similar tool. I'd then try parsing the date using the specified format:

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.Date-method-parse

Just try running it in Firebug:


Ext.Date.parse('date captured from the response', 'MS');

Check that it parses as expected.

Next I'd trying grabbing the records out of the store and checking that they contain the dates I'm expecting.

gigofizz
21 Dec 2011, 7:16 AM
The problem wasin the database, had empty fields.
Examples:'12/12/2009
'

Solution:

Use fuction TRIM PHP remove spaces

PHP
----
service.php

$row["stc_dfecha_desde_1"]=trim($rs["stc_dfecha_desde_1_format"]);

Thanks you for your help.