Page 73 of 84 FirstFirst ... 2363717273747583 ... LastLast
Results 721 to 730 of 837

Thread: [new version] DateTime Field

  1. #721
    Ext JS Premium Member
    Join Date
    Dec 2009
    Posts
    11

    Default Issue setting default time value

    Hi, I'm using the DateTime field in an EditorGridPanel, and I'm having trouble setting a default time value. Here is my grid column config - in the timeConfig I am using the value attribute to default the time to '6:00'. Any ideas?
    Thanks!

    Code:
    {                         header: 'Start Date',                          
       width: 110,                         
       sortable: true,                          
       dataIndex: 'startDateString',                         
       renderer: myFormatDate,                         
       editor: new Ext.ux.form.DateTime(
                 {                             dateFormat:'m/d/Y',                             
                    timePosition: 'below',                             
                    dateConfig: {                                 allowBlank: true},                             
                    timeFormat:'G:i',                             
                    timeConfig: {                                 allowBlank: true,                                 value: '6:00',                                 triggerAction: 'all'                                                             },                             
                    otherToNow: false                         
                 })                     
    }

  2. #722
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664

    Default

    I'm having trouble setting a default time value
    What shows instead of 6:00? 'Cause your config seems to be correct. Or try 06:00.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


  3. #723
    Sencha User
    Join Date
    Jul 2010
    Posts
    17

    Default

    I was using the code at the beginning of the topic (I assume it is the one you have been keeping updated), and ran into a small issue, with regards to parsing the initial date-time value:

    I am using it in an EditorGridPanel, with data populated using a JSONStore. In certain cases the date-time value comes back with only the date value. When this happens and I go to the edit the value I find myself with a date of 1 Jan 1970. Looking at the code the issue is in the setValue() method. Basically the logic in

    else if('string' === typeof val && this.hiddenFormat)


    block will cause val to be null and thus cause the val to be redefined in the test case following it:

    val = val ? val : new Date(1970, 0 ,1, 0, 0, 0);

    this means the following 'if-else' block will never enter the else section, which is able to handle date only values. I change the code thus:

    Code:
        ,setValue:function(val) {
            if(!val && true === this.emptyToNow) {
                this.setValue(new Date());
                return;
            }
            else if(!val) {
                this.setDate('');
                this.setTime('');
                this.updateValue();
                return;
            }
            if ('number' === typeof val) {
              val = new Date(val);
            }
            else if('string' === typeof val && this.hiddenFormat) {
                var oldVal = val;
                val = Date.parseDate(val, this.hiddenFormat);           
                // INFO if val is null use the original value, since we will try below
                if ( !val ) {
                    val = oldVal;
                }
            }
            val = val ? val : new Date(1970, 0 ,1, 0, 0, 0);
            var da;
            if(val instanceof Date) {
                this.setDate(val);
                this.setTime(val);
                this.dateValue = new Date(Ext.isIE ? val.getTime() : val);
            }
            else {            
                da = val.split(this.dtSeparator);
                this.setDate(da[0]);
                if(da[1]) {
                    if(da[2]) {
                        // add am/pm part back to time
                        da[1] += da[2];
                    }
                    this.setTime(da[1]);
                }
            }
            this.updateValue();
        } // eo function setValue
    The modified code is following the "INFO" comment.

  4. #724
    Sencha User Dumas's Avatar
    Join Date
    Dec 2008
    Location
    Vienna, Austria
    Posts
    589

    Default

    Hi!

    I have a datetime field with this config:
    Code:
    {
                xtype:'xdatetime',
                name: 'till',
                fieldLabel: 'End date', 
                hiddenFormat:'d.m.Y H:i', // that's how the components reads the date if it's not a date object
                timeFormat:'H:i',
                timeConfig: {
                    altFormats:'H:i',
                    allowBlank:false
                },
                dateFormat:'d.m.Y',
                dateConfig: {
                    altFormats:'d.n.Y|d.m.Y',
                    allowBlank:false
                }
    When I load the field with a date like "30.09.2010 13:12" it is displayed right, but it sends exactly "30.09.2010 13:12" to the server. When I change the date it is send like this: "30.09.2010T13:12"

    What do I have to do so everything is send in the same format?

    thx
    Dumas

  5. #725
    Ext User
    Join Date
    Jun 2010
    Posts
    13

    Default an issue with form reset

    Hi Saki,

    Sorry if this has been discussed before in this long thread ...

    I am using your DateTime ux on ExtJs 3.2.1, but I'm having problems with the 'reset' functionality.

    When loading a form using 'trackResetOnLoad', if I change the ux original loaded value it works ok, but if I execute 'reset' in the form, the ux does not set the correct value internally (even though it shows the correct values in the composite fields), and therefore it does not send the correct value to the server.

    I believe this could be resolved as follows:

    Code:
    	,reset:function() {
    		// this.df.setValue(this.originalValue);
    		// this.tf.setValue(this.originalValue);
    		this.setValue(this.originalValue);
    	}
    Unless I'm doing something wrong or you recommend otherwise?.

    Best regards,

    Lobo

  6. #726
    Sencha Premium User NoahK17's Avatar
    Join Date
    Apr 2008
    Location
    Atlanta, GA
    Posts
    538

    Default

    Quote Originally Posted by ajmas View Post
    I was using the code at the beginning of the topic (I assume it is the one you have been keeping updated), and ran into a small issue, with regards to parsing the initial date-time value:

    I am using it in an EditorGridPanel, with data populated using a JSONStore. In certain cases the date-time value comes back with only the date value. When this happens and I go to the edit the value I find myself with a date of 1 Jan 1970. Looking at the code the issue is in the setValue() method. Basically the logic in

    else if('string' === typeof val && this.hiddenFormat)


    block will cause val to be null and thus cause the val to be redefined in the test case following it:

    val = val ? val : new Date(1970, 0 ,1, 0, 0, 0);

    this means the following 'if-else' block will never enter the else section, which is able to handle date only values. I change the code thus:

    Code:
        ,setValue:function(val) {
            if(!val && true === this.emptyToNow) {
                this.setValue(new Date());
                return;
            }
            else if(!val) {
                this.setDate('');
                this.setTime('');
                this.updateValue();
                return;
            }
            if ('number' === typeof val) {
              val = new Date(val);
            }
            else if('string' === typeof val && this.hiddenFormat) {
                var oldVal = val;
                val = Date.parseDate(val, this.hiddenFormat);           
                // INFO if val is null use the original value, since we will try below
                if ( !val ) {
                    val = oldVal;
                }
            }
            val = val ? val : new Date(1970, 0 ,1, 0, 0, 0);
            var da;
            if(val instanceof Date) {
                this.setDate(val);
                this.setTime(val);
                this.dateValue = new Date(Ext.isIE ? val.getTime() : val);
            }
            else {            
                da = val.split(this.dtSeparator);
                this.setDate(da[0]);
                if(da[1]) {
                    if(da[2]) {
                        // add am/pm part back to time
                        da[1] += da[2];
                    }
                    this.setTime(da[1]);
                }
            }
            this.updateValue();
        } // eo function setValue
    The modified code is following the "INFO" comment.
    Your updated code worked perfectly. Thanks!

    I also was having trouble setting the default time and date values, but I discovered that the UX is very picky with regards to formatting.

    Dates have to be 04/01/2010 (leading zero) and Time has to be 06:00 (24 hour clock with leading zero).

    Hope that saves someone else some frustration!
    Noah
    Front-End Developer
    Norfolk Southern

  7. #727
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664

    Default

    @Lobo, have you tested it? I'd suppose that you should only add the line and not comment the existing lines.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


  8. #728
    Ext User
    Join Date
    Jun 2010
    Posts
    13

    Default

    Quote Originally Posted by jsakalos View Post
    @Lobo, have you tested it? I'd suppose that you should only add the line and not comment the existing lines.
    So far it works based on the little testing I've done.

    From what I've checked, the 'setValue' on DateTime already takes care of setting the passed (originalValue) date/time, so I believe it would be redundant if we don't comment those lines.

    But then again, I have NOT tested all cases.

  9. #729
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,664

    Default

    Yeah, that's true. I haven't had sources handy when I answered, now I see that one call is enough. My very brief test also says that it works.
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid MultiSearch Plugin, Grid MultiSort Plugin, Configuring ViewModel Hierarchy


  10. #730
    Ext JS Premium Member
    Join Date
    Feb 2009
    Posts
    487

    Default

    Can I ask - while the docs say the default hidden format is mysql format, when I ajax submit a form having collected the filed values with getFieldValue(), the date format submitted is actually JSON format? i.e. 2010-09-09T00:00:00 and not 2010-09-09 00:00:00 as expected.

Page 73 of 84 FirstFirst ... 2363717273747583 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •