Reputation: 11
I want to set yesterday value to my datepicker
items: [
{
title: 'Start Date',
margin: '0 20 0 0',
header: {
titleAlign: 'center'
},
items: {
xtype: 'datepicker',
itemId: 'startDate',
value: Ext.Date.add(new Date(), Ext.Date.DAY, -1),
showToday: false,
handler: function (picker, date)
{
var endDate = picker.up('form').down('#endDate').getValue();
var oneDay = 24 * 60 * 60 * 1000;
var diffDays = Math.round(Math.abs((endDate.getTime() - date.getTime()) / (oneDay)));
}
}
}
]
using button
{
xtype: 'button',
cls: 'datePickerSearchBtn',
text: 'Yesterday',
listeners: {
click: function () {}
}
}
How can i do that?
Upvotes: 1
Views: 1411
Reputation: 4196
Just use Ext.picker.Date.setValue() method, like this
datepicker.setValue(Ext.Date.add(new Date(), Ext.Date.DAY, -1));
Check this fiddle.
Upvotes: 2