I dont understand how to create two date columns and create range between them?
For example I have Grid where is some column (deadline date), and i have 2 datefields, where I can write: From what day and Till what day .
How then I can filter data between those days that I choosed?
**SOME CODE:**
// create the Grid
var grid = new Ext.grid.GridPanel({
store : store,
id : 'grid',
columns : [
new Ext.grid.RowNumberer({width: 20, header: '#'}),
{id:'text',header: "Text", width: 150, sortable: true, dataIndex: 'text'},
{id:'is_online',header: "Is Online?", width: 70, sortable: true, dataIndex: 'is_online'},
{id:'deadline',header: "Deadline", width: 130, sortable: true, dataIndex: 'deadline', xtype: "datecolumn", format: "Y-m-d"}
],
stripeRows : true,
height : 550,
title : 'Questions',
});
var gridSearch = new Ext.Panel({
stripeRows : true,
frame : true,
style : 'padding-bottom: 5px',
height : 250,
title : 'Search filter',
items : [{
xtype : 'checkbox',
id : 'is_for_online',
boxLabel : 'Показать только ОНЛАЙН',
inputValue : '1'
},{
xtype : 'datefield',
id : 'date_s',
allowBlank : true,
emptyText : 'Выберите дату С',
name : 'deadline',
width : 140,
editable : false,
format : 'Y-m-d'
},{
xtype : 'datefield',
id : 'date_s',
allowBlank : true,
emptyText : 'Выберите дату С',
name : 'deadline',
width : 140,
editable : false,
format : 'Y-m-d'
},{
xtype : 'button',
text : 'Go!',
handler : function () {
//var searchValueDate1 = Ext.getCmp("date_s").getValue();
//var searchValueDate2 = Ext.getCmp("date_po").getValue();
//var date_s = searchValueDate1.format('Y-m-d');
//var date_po = searchValueDate2.format('Y-m-d');
//store.filter("deadline", date_s)//, date_po);
alert(daterange);
}
},
]
});
So what you want to do is have a user select a start and end date and in the grid filter out and show only the records with deadline dates between that range? Say you have field where the user enters the date range and click a button to filter on the filter button click. Get the date range from the two fields (I assume you’ll have logic to make sure the user has enter a valid date range ie the start date is before the end date etc.)
Then try the following:
On the button click handler below