I am using the Enterprise version of the AgGrid. and want to apply a custom filter on the grid.
How can I set the select radio box value to grid metadata?
ref code below:
gridOptions={
....
columnDef : [{
headerName : "Last Updated",
field : "lastUpdated",
width:columnWidth(gridElementname,9),
filter : *DateFilter,
cellRenderer : '*CellRenderer',
},...];
rowModelType: 'serverSide',
}
// Custom Filter
function *DateFilter() {
}
*DateFilter.prototype.init = function(params) {
this.eGui = document.createElement('div');
this.eGui.innerHTML =`
<input type="radio" name="timeFilter" id="dateToday" value = "1"><label>Added Today</label><br>
<input type="radio" name="timeFilter" id="datePast7" value = "2"><label> Past 7 days</label><br>
`;
this.dateToday = this.eGui.querySelector('#dateToday');
this.datePast7 = this.eGui.querySelector('#datePast7');
this.dateToday.addEventListener('change', this.onRbChanged.bind(this));
this.datePast7.addEventListener('change', this.onRbChanged.bind(this));
this.filterActive = false;
this.filterChangedCallback = params.filterChangedCallback;
this.valueGetter = params.valueGetter;
};
*DateFilter.prototype.getGui = function() {
return this.eGui;
};
*DateFilter.prototype.onRbChanged = function() {
this.dateToday.filterActive = this.dateToday.checked;
this.datePast7.filterActive = this.datePast7.checked;
this.filterChangedCallback();
};
*DateFilter.prototype.isFilterActive = function() {
if(this.dateToday.filterActive == true)
return this.dateToday.filterActive;
else if(this.datePast7.filterActive == true)
return this.datePast7.filterActive;
};
*DateFilter.prototype.doesFilterPass = function(params) {
return true;
};
*DateFilter.prototype.getModel = function() {
};
*DateFilter.prototype.setModel = function() {
};
Also implemented External filter but this approach is not helping here.
var externalFilter = {'fieldName' : { type: 'contains', filter: 101 }};
gridOptions.api.setFilterModel(externalFilter);
Thanks In advance. :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…