0
votes

enter image description here

I have a requirement where I have to apply dynamic date filters on an ExtJS grid on load(i fetch dates from response).I tried but it is not showing the filtered date nor it is marking the "before/after/on" fields of the filter column.please help

This is the code I have used,

grid.filters.addFilter({ 
    type: 'date', 
    operator: "eq", 
    value: "11/15/2016",
    dataIndex: gridCols[i].dataIndex,
    active: true 
});
1
Can you put your efforts on sencha FIDDLE ? - Narendra Jadhav
The value has to be a date. Try value: Ext.Date.parse("11/15/2016", "m/d/Y") - Alexander
@Alexander Please see the code i mentioned below - Adithya
@Njdhv Please refer the below code - Adithya

1 Answers

0
votes
     var onDate = Ext.Date.add(new Date(dt), Ext.Date.DAY); //converting date from String to Date format.
//variable dt has date in string format eg:"11/15/2016"
     grid.columns[i].filter.setActive(true);
     grid.columns[i].filter.setValue({ lt: onDate }); //lt,gt,eq are the fields of the date filter
     grid.columns[i].filter.fields.lt.value = onDate;
  • So in this way am setting the filters from response dynamically.
  • But make sure to load the menu of the grid column in "afterrender" event of grid as the menu items of date filter wont be loaded in background until we open its corresponding filter. So they wont be checked.

     if (!grid.getView().headerCt.menu) {
        grid.getView().headerCt.getMenu();
    }