1. #1
    Sencha User
    Join Date
    Mar 2009
    Posts
    227
    Vote Rating
    0
    SchattenMann is an unknown quantity at this point

      0  

    Default Datepicker - Value and Events issue

    Datepicker - Value and Events issue


    Greetings

    When trying to define a default value for a datepicker field i come across the following issue.

    In designer Value must be a valid date meaning we can't have something like
    Code:
    value: new Date(),
    picker: {
           yearFrom: new Date().getFullYear() - 1,
           yearTo: new Date().getFullYear() + 1
    }
    that forced me to use events to dynamically set those values.

    unfortunately events seems to don't work (or i'm doing something else wrong) in this case.

    i'm using designer for everything and thats the code i got:

    Code:
    {
                            xtype: 'datepickerfield',
                            itemId: 'datadoc',
                            label: 'Data Doc.',
                            name: 'datadoc',
                            required: true,
                            dateFormat: 'd/m/Y'
                        }
    Code:
    listeners: [
                {
                    fn: 'onDatadocInitialize',
                    event: 'initialize',
                    delegate: '#datadoc'
                }
            ]
    Code:
    onDatadocInitialize: function(component, options) {
            component.setValue(new date());
        }
    no matter what event i use (show, activate, whatever) it never get's fired for some reason...

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,176
    Vote Rating
    119
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    I'd recommend overriding initComponent via an overrides class.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Location
    Hong Kong
    Posts
    6
    Vote Rating
    0
    fc338339 is on a distinguished road

      0  

    Default


    Quote Originally Posted by aconran View Post
    I'd recommend overriding initComponent via an overrides class.
    I also have the same queries on add current date and time , please explain in details,

    Thanks

    In my case, I need to add date and time into my Model, so I got below problem

    Q1. I am not sure to handle date and time into one field by dateformat [Y-m-d g:i a] or separate into two field that itemDate and itemTime in the Model

    Q2. there is no type as timestamp for time field, so how to handle it, for example the type of itemTime is still using "date" while the dateformat is [g:i a] ?

    Q3. when I activate the form with datepicker , how to auto generate the currency date and time ?

    I have tried to referred the sencha touch 2 examples : picker and add an activate event to the datepicker as follows:

    onItemDdatepickerActivate: fucntion(container, newActiveItem, oldActiveItem, options) {
    this.picker.setValueAnimated(new Date());
    }
    of course the script is failed to show the current date.

    please helps

    thanks

  4. #4
    Sencha User
    Join Date
    Mar 2009
    Posts
    227
    Vote Rating
    0
    SchattenMann is an unknown quantity at this point

      0  

    Default


    Quote Originally Posted by aconran View Post
    I'd recommend overriding initComponent via an overrides class.
    i would also need some guidance on this

  5. #5
    Sencha User
    Join Date
    Mar 2009
    Posts
    227
    Vote Rating
    0
    SchattenMann is an unknown quantity at this point

      0  

    Default


    out of ideas...

  6. #6
    Sencha User
    Join Date
    Mar 2009
    Posts
    227
    Vote Rating
    0
    SchattenMann is an unknown quantity at this point

      0  

    Default


    i seriously have no idea what i'm doing wrong.

    Option A - Not Working
    Code:
    Ext.define('MyApp.view.MyFormPanel', {
        extend: 'Ext.form.Panel',
    
        config: {
            items: [
                {
                    xtype: 'datepickerfield',
                    itemId: 'mydatefield',
                    label: 'Field',
                    placeHolder: 'mm/dd/yyyy'
                }
            ],
            listeners: [
                {
                    fn: 'onMydatefieldInitialize',
                    event: 'initialize',
                    delegate: '#mydatefield'
                }
            ]
        },
    
        onMydatefieldInitialize: function(component, options) {
    
            Ext.Msg.alert('Title','teste');
        }
    
    });
    Option B - Working

    Code:
    Ext.define('MyApp.view.MyFormPanel', {
        extend: 'Ext.form.Panel',
    
        config: {
            items: [
                {
                    xtype: 'datepickerfield',
                    itemId: 'mydatefield',
                    label: 'Field',
                    placeHolder: 'mm/dd/yyyy',
                    listeners: {
                        initialize: function(list, opts){
                            Ext.Msg.alert('buh','teste');
                        }
                    }
                }
            ]
        }
    
    });
    Unfortunately i can't use the option B in Designer so i'm kinda stuck.

    I also have tried creating a ref and using it in a controller...without success.

  7. #7
    Sencha User
    Join Date
    Mar 2009
    Posts
    227
    Vote Rating
    0
    SchattenMann is an unknown quantity at this point

      0  

    Default


    after a lot of tests i realize not all events get fired.

    meaning that if i use Option A (With delegate) events like show and initialize are not fired but others like focus and change are...

    bug?

  8. #8
    Sencha - Architect Dev Team jjohnston's Avatar
    Join Date
    Sep 2010
    Posts
    516
    Vote Rating
    17
    jjohnston will become famous soon enough jjohnston will become famous soon enough

      0  

    Default


    That's interesting, I can verify that the initialize event (and some others) does not fire when set up with delegation.

    As a workaround, you can do this:

    - Add an 'initialize' event binding to the Form Panel (not the field)
    - Set its handler code to:
    this.down('#mydatefield').setValue(new Date());

    We will be fixing Designer to allow using Date object values directly in the config so you don't have to do this in code.
    Jason Johnston
    @lojjic
    Sencha Architect Development Team

  9. #9
    Sencha User
    Join Date
    Mar 2009
    Posts
    227
    Vote Rating
    0
    SchattenMann is an unknown quantity at this point

      0  

    Default


    Quote Originally Posted by jjohnston View Post
    That's interesting, I can verify that the initialize event (and some others) does not fire when set up with delegation.
    Glad i can help. I was starting to think i was crazy lol

    Quote Originally Posted by jjohnston View Post
    As a workaround, you can do this:

    - Add an 'initialize' event binding to the Form Panel (not the field)
    - Set its handler code to:
    this.down('#mydatefield').setValue(new Date());
    That was the workaround i've found too. thanks.

    Quote Originally Posted by jjohnston View Post
    We will be fixing Designer to allow using Date object values directly in the config so you don't have to do this in code.
    that was great. thanks.
    i would also like to suggest the ability to add custom property as an object or function. we can add custom property to a field but since they are escaped we can only add strings. it would be nice the ability to add functions. (this way we could force handler: function() for example)

  10. #10
    Sencha User
    Join Date
    Mar 2009
    Posts
    227
    Vote Rating
    0
    SchattenMann is an unknown quantity at this point

      0  

    Default


    ic...i was trying to do myBoolean - Add - True

    thanks aconran

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi