PDA

View Full Version : RowEditor Date Formating Problem



Jack_S
6 Aug 2009, 4:49 AM
Hello,

I'm using the Row Editor but even after updating a datefield the rowEditor seems to ignore any renderer or formating. Its actually doesn't pull the raw value.

In short, the value of the datefield is 2009-8-17 rather then 17/08/2009. Can anybody offer any suggestions.



xtype: 'datecolumn'
,header: 'Install Date'
,dataIndex: 'install_date'
,align: 'center'
,width: 75
,format: 'd/m/Y'
,sortable: true
,renderer: this.renderDate
//,renderer: Ext.util.Format.dateRenderer('d/m/Y')
,editor: {
xtype: 'datefield'
,allowBlank: true
}

Here is an additional render I attempted to use but without success



,renderDate:function(val){
return val.dateFormat('d/m/Y');
}

Jack_S
10 Aug 2009, 2:07 AM
Hello All,

As no one was able to answer, I'm curious if there is a way to override the entire date formating. Here in the Czech Republic we always use d/m/Y. How can I override this in order to not have to apply additional rendered nor deal with the rawValue of the datefield.

Regards

Jack

Condor
10 Aug 2009, 2:17 AM
The field value in the store needs to be a Date for this to work correctly.

Did you configure your record correctly (type:'date', dateFormat:'....')?

Jack_S
11 Aug 2009, 12:39 AM
Hello Condor,

Yes I have done this but I'm still getting a date formate in form of Y-m-d.


,{name: 'install_date', type: 'date', dateFormat: 'd/m/Y'}

Been trying to figure this one out, but nothing seems to be fixing the formating issue.

Thanks

Jack

Condor
11 Aug 2009, 12:57 AM
Your datefield editor needs a format too.

Jack_S
11 Aug 2009, 2:40 AM
Hello Condor,

I have tried this and many other things and at this point I cannot understand why the datecolumn and datefield containt date format of "Y-m-d".

All date formats are setup correctly but when I update the row, its not getting the rawValue of the datefield. At least this is what it appears to be doing.

Any suggestions on how to overcome this?

Thanks

Jack



Record def...
,{name: 'install_date', type: 'date', dateFormat: 'd/m/Y'}


Column Def.....
{
xtype: 'datecolumn'
,header: 'Install Date'
,dataIndex: 'install_date'
,width: 100
,format: 'd/m/Y'
,sortable: true
,editor: {
xtype: 'datefield'
,allowBlank: true
,format: 'd/m/Y'
}
}

Condor
11 Aug 2009, 2:44 AM
Where is this Y-m-d date coming from? Are you sure your server is not sending dates using thie format?

Jack_S
11 Aug 2009, 11:29 PM
Hello Condor,

When I grab the rawValue of the datefield component, then I'm send over to the database a value in the format d/m/Y.

When I add a new record, the datafield is empty, as soon as I update the date, then format sent to the database is Y-m-d, which tells me that this might have to do with the compoenent itself.

Is there a way to override the date formats used by the datefield component?

Thanks

Jack

Condor
12 Aug 2009, 1:43 AM
What do you mean by database? The store or the real database on the server?

Jack_S
12 Aug 2009, 2:49 AM
Hello Condor,

I mean the actual database.

Thx

Jack

Condor
12 Aug 2009, 2:50 AM
Are you using a writer or did you write your own code to send the modified data to the server?

Jack_S
12 Aug 2009, 5:05 AM
Hello Condor,

I'm using a WRITER as demonstrated in the sample/demos of the rowEditor.
The sends over a JSON string which I parse on the database end and then update the database record accordingly.

Here is how I've configured the store, reader and writer.

Thanks

Jack



,store: new Ext.data.GroupingStore({
proxy: new Ext.data.HttpProxy({
//method: 'POST'
api: {
read : baseURL + '/oriflame.line_lookup'
,create : baseURL + 'oriflame.create_line'
,update: baseURL + '/oriflame.update_line'
,destroy: baseURL + '/oriflame.delete_line'
}
}),
remoteSort: true
,sortInfo:{field:'line_id', direction:'ASC'}
,reader: new Ext.data.JsonReader({
root: 'results',
idProperty: 'line_id',
totalProperty: 'total',
successProperty: 'success'
}, this.recordObj),
writer: new Ext.data.JsonWriter({
encode: true,
writeAllFields: false
}),
//autoSave: true,
listeners: {
write : function(store, action, result, res, rs) {
//App.setAlert(res.success, res.message); // <-- show user-feedback for all write actions
Ext.Msg.show({
title: 'Success',
msg: 'Success',
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
},
exception : function(proxy, type, action, options, res, arg) {
if (type === 'remote') {
Ext.Msg.show({
title: 'REMOTE EXCEPTION',
msg: res.message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
}
}
}
})

Condor
12 Aug 2009, 5:34 AM
By default JsonWriter (with encode:true) will encode the data using Ext.util.JSON.encode, which will encode dates as 'Y-m-dTH:i:s'.

If you don't want that you should either supply your own encode to JsonWriter or replace the default date encoding:

Ext.util.JSON.encodeDate = function(o){
return o.dateFormat('d/m/Y');
}
(but remember that will will affect ALL JSON encoding!)

Jack_S
13 Aug 2009, 1:37 AM
Hello Condor,

Thanks a lot for your assistance, that was the fix that I needed.

Regards

Jack