Reputation: 699
I try to filter an ExtJS4 grid by date.
I have two columns that I fill like this:
{header: 'Start Date', width: 80, dataIndex: 'startdate', filter: { type: 'date', dateFormat: 'Y-m-d'}},
{header: 'End Date', width: 80, dataIndex: 'enddate', filter: { type: 'date', dateFormat: 'Y-m-d'}},
In the grid I see a the date in the right format, but the second I want to filter (before, after, on), I always get an empty result. My data store is local (no ajax) and I want to filter that locally.
Even changing it to the default Y/m/d doesn't seem to work.
Upvotes: 1
Views: 2056
Reputation: 47
Try this!
var filter = {
ftype: 'filters',
encode: false,
local: false,
filters: [{
// required configs
type: 'date',
dataIndex: 'startdate',
// optional configs
dateFormat: 'm/d/Y', // default
beforeText: 'Before', // default
afterText: 'After', // default
onText: 'On', // default
},{
// required configs
type: 'date',
dataIndex: 'enddate',
// optional configs
dateFormat: 'm/d/Y', // default
beforeText: 'Before', // default
afterText: 'After', // default
onText: 'On', // default
}]};
var Grid = new Ext.grid.GridPanel({
id: 'Grid',
store: store...,
features: [ filter ],
columns : [...]
});
Also you can look example here: http://docs.sencha.com/extjs/4.0.7/#!/api/Ext.ux.grid.filter.DateFilter
Upvotes: 0
Reputation: 699
Reason for this was a missing type in the model.
Before:
{name: 'startdate'},
{name: 'enddate'},
After:
{name: 'startdate', type: 'date'},
{name: 'enddate', type: 'date'},
Credits to Amensrine! Thanks!
Upvotes: 2