1. #1
    Sencha User
    Join Date
    Jul 2009
    Posts
    51
    Vote Rating
    0
    fruitwerks is on a distinguished road

      0  

    Default Ext.form.DateField - formatting ignored?

    Ext.form.DateField - formatting ignored?


    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.

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

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Confused.

    EditorGridPanels don't submit anything.

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

  3. #3
    Sencha User
    Join Date
    Jul 2009
    Posts
    51
    Vote Rating
    0
    fruitwerks is on a distinguished road

      0  

    Default


    I am using the date picker within an editor grid.

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    How have you set up the editor grid to communicate with ther server?

  5. #5
    Sencha User
    Join Date
    Jul 2009
    Posts
    51
    Vote Rating
    0
    fruitwerks is on a distinguished road

      0  

    Default


    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!

  6. #6
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    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!

  7. #7
    Sencha User
    Join Date
    Jul 2009
    Posts
    51
    Vote Rating
    0
    fruitwerks is on a distinguished road

      0  

    Default


    hmm...

    Code:
    var grid = new Ext.grid.EditorGridPanel
    ...
    Code:
    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!

  8. #8
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    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.

  9. #9
    Sencha User
    Join Date
    Jul 2009
    Posts
    51
    Vote Rating
    0
    fruitwerks is on a distinguished road

      0  

    Default


    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!

  10. #10
    Sencha User
    Join Date
    Jul 2009
    Posts
    51
    Vote Rating
    0
    fruitwerks is on a distinguished road

      0  

    Default


    I eventually came up with this...

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

Thread Participants: 1