Andrei
Andrei

Reputation: 1203

ExtJs 3. Display calendar by clicking on text field

how to show a calendar when you click on text field icon on the left of the calendar?

enter image description here

Upvotes: 0

Views: 1433

Answers (3)

Muzaffer Galata
Muzaffer Galata

Reputation: 642

Alin Suciu's answer is not enough for extjs 5. Because when click datepicker image, picker does not trigger. So i changed it a little. it's not best way but working.

listeners: {
    afterrender: function (d) {
        d.getEl().on('click', function (e, t, o) {
            if (e.target.id.indexOf('picker') <= 0) {
                d.onTriggerClick();
            }
        });
    }
}

if there is any better solution advice, i will change my code. Best regards.

Upvotes: 0

user1249679
user1249679

Reputation:

 {
xtype:'datefield', 
fieldLabel:'Start Date', 
name:'start_date',
dataIndex:'start_date'
}

use the items[] for the field container and put above lines for datefield in items and call it 

Upvotes: 1

Alin Suciu
Alin Suciu

Reputation: 121

Use the 'render' event to listen to clicks on the datefield, then use the onTriggerClick() function to expand the date picker:

       {
            xtype:'datefield',
            name:'date1',
            fieldLabel:'Date',
            listeners:{
                render:function (d) {
                    d.el.on('click', function () {
                        d.onTriggerClick();
                    });

                }
            }
        }

Upvotes: 1

Related Questions