Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.9k views
in Technique[技术] by (71.8m points)

javascript - Ag grid Enterprise Server side Custom Filter not working

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>&nbsp;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. :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
...