请看看这个笨蛋 https://plnkr.co/edit/cOuQ5YPdQDl6oDvoUSSn?p=preview 如果我在任何列上放置过滤器,例如从 Gold 中删除 8 个,那么总数应该会刷新。如何实现这一点
在此处输入代码功能
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;
};
最佳答案
它没有更新,因为它与可见数据无关,它绑定(bind)到真实数据(不可变的内存数据)
但可以肯定的是,您可以创建一个解决方法并自己处理 pinnedData
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)
}
将此部分添加到您的gridOptions
中。
One notice: currently we should use
setTimeout
insideonFilterChanged
cuzgrid
doesn't provide updated data inside this event, theag-grid
team informed aboutAG-2078 Filter Cell Renderer refreshes before grid has finished updating
关于AG-grid 刷新固定行的总计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53057323/