PDA

View Full Version : Ext.form.DateField - formatting ignored?



fruitwerks
14 Aug 2009, 11:40 AM
I have an editorgrid and a few date fields, when I edit these using the Ext.form.DateField, it returns a very detailed string to the server.


Wed Jul 25 1900 00:00:00 GMT-0500 (Central Daylight Time)

All I need is m-d-Y, and I have specified that within my editor and the column model. When I manually enter dates to the db in the proper form YYYY-MM-DD, they render fine in the grid. How to I change the output of the date picker to store my desired format?

Thanks!

Animal
14 Aug 2009, 11:42 AM
Confused.

EditorGridPanels don't submit anything.

So. You have some DateFields in a form which you are submitting?

fruitwerks
14 Aug 2009, 11:51 AM
I am using the date picker within an editor grid.

Animal
14 Aug 2009, 11:57 AM
How have you set up the editor grid to communicate with ther server?

fruitwerks
14 Aug 2009, 12:02 PM
Good question, and I was fearing that might be my issue. At current afteredit performs a commit, possibly not giving the date a chance to get formatted?

I would like to have an 'update' button to commit all the dirty fields once I am done editing.

Thanks!

Animal
14 Aug 2009, 12:04 PM
You using some of this new Ext.direct stuff? I mean you can't just use a normal EditorGridPanel and expect to update the server in any way!

fruitwerks
14 Aug 2009, 12:08 PM
hmm...


var grid = new Ext.grid.EditorGridPanel
...

listeners: {
afteredit: function(e) {
var conn = new Ext.data.Connection();
conn.request({
url: 'quickchart.php?act=update',
params: {
id: e.record.id,
field: e.field,
value: e.value
},
success: function(resp, opt) {
grid.getStore().getById(opt.params.id).commit();
},
failure: function(resp, opt) {
grid.getStore().getById(opt.params.id).reject();
}
});

I guess that is my problem then... Very dirty and dangerous, I just set it up that way for testing - I think I will work on adding that update button now :)

Thanks!

Animal
14 Aug 2009, 12:14 PM
OK, you just use e.value? It's a Date, and what do you EXPECT it to do? Read your mind?

It just does a toString()

If you want it formatted, format it.

fruitwerks
14 Aug 2009, 1:46 PM
Thanks for the info! This is all new to me :) I need to step back and take a different look at the project.

Thanks Again!

fruitwerks
14 Aug 2009, 5:49 PM
I eventually came up with this...


listeners: {
afteredit: function(e) {
var value = Ext.isDate(e.value) ? e.value.format("Y-m-d") : e.value;
console.log(e.value);
var conn = new Ext.data.Connection();
conn.request({
url: 'quickchart.php?act=update',
params: {
id: e.record.id,
field: e.field,
value: value
}.......

Thanks!

Animal
14 Aug 2009, 10:43 PM
Did you look in Firebug at the posted data?

Take a look at it. It will be funny.

fruitwerks
15 Aug 2009, 11:22 AM
Not sure what you are hinting at, it all works fine.

Thanks!