2
votes

Please see this plunker https://plnkr.co/edit/cOuQ5YPdQDl6oDvoUSSn?p=preview If i put filter on any column, eg from Gold i remove 8 then the total should get refreshed. How can this be achieved

enter code herefunction

CustomPinnedRowRenderer () {}

CustomPinnedRowRenderer.prototype.init = function(params) {
    this.eGui = document.createElement('div');
    this.eGui.style = params.style;
    this.eGui.innerHTML = params.value;
};

CustomPinnedRowRenderer.prototype.getGui = function() {
    return this.eGui;
};
1

1 Answers

2
votes

It's not updated cuz it doesn't relate with visible data, it's binding to real (immutable, memory data)

But for sure you can create a workaround and handle pinnedData by yourself

onFilterChanged:(params)=>{
    let result = {
        gold:0,
        silver:0,
        bronze:0
    }
    setTimeout(()=>{
        params.api.forEachNodeAfterFilter(i=>{
            result.gold += Number(i.data.gold);
            result.bronze += Number(i.data.bronze);
            result.silver += Number(i.data.silver);
        });
        console.log(result);
        params.api.setPinnedTopRowData([result]);
    },0)
}

Add this part to your gridOptions.

One notice: currently we should use setTimeout inside onFilterChanged cuz grid doesn't provide updated data inside this event, the ag-grid team informed about

AG-2078 Filter Cell Renderer refreshes before grid has finished updating