Results 1 to 2 of 2

Thread: how to show current time in timefield

  1. #1
    Sencha User
    Join Date
    Dec 2009
    Posts
    425

    Default how to show current time in timefield

    Hi,
    My grid has a timefield.
    When the editor kicks in I need the timefield to show the current hour.
    Using value property did not work.
    Code:
    {
        header: "Time",
        width: 80,
        dataIndex: 'time',
        sortable: true,
        editor: {
            xtype: 'timefield', // rules about editing
            allowBlank: false,
            minValue: '12:00 AM',
            maxValue: '11:00 PM',
            increment: 60,
            format: 'g:i A',
            value: Ext.util.Format.date(new Date(), 'g:00 A'),
            style: {
                float: 'left'
            }
        },
        align: 'left'
    }
    Please help.

  2. #2

    Default

    The line value: Ext.util.Format.date(new Date(), 'g:00 A') seems to work for me. I am wondering if it is how you are creating your field. When I use the rowEditor I add it to the column which I have promoted to a class. You could try this.

    Code:
    {
        header: "Time",
        width: 80,
        dataIndex: 'time',
        sortable: true,
        editor: new Ext.form.TextField({ // rules about editing
            allowBlank: false,
            minValue: '12:00 AM',
            maxValue: '11:00 PM',
            increment: 60,
            format: 'g:i A',
            value: Ext.util.Format.date(new Date(), 'g:00 A'),
            style: {
                float: 'left'
            })
        },
        align: 'left'
    }
    My other thought is that you could try setting the value of the field after you have created it. So something like myDateField.setValue(Ext.util.Format.date(new Date(), 'g:00 A');

Posting Permissions

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