我的问题是我的网格根本不会保持代表性,或者如果我尝试创建一个网格而不是很多列,整个网格看起来很奇怪。我希望它伸展到它的容器宽度。这就是我所期望的尺寸.ColumsToFit要做的事情。我收到警告:s
但我怎么解决这个问题。例如,我从reducer加载数据,因此会发生重新渲染,或者当我的数据处于获取状态时,我有一个加载微调器。你们采取什么模式来解决这个问题?
site
继承我的渲染方法:
ag-Grid: tried to call sizeColumnsToFit() but the grid is coming back with zero width, maybe the grid is not visible yet on the screen?
编辑:我怀疑所有发生的事情,网格合法并不知道onGridReady中的宽度,因为dom还没有完成加载,但其他一切都已初始化。如果我这样做:onGridReady(params) {
const { mode } = this.props;
this.gridApi = params.api;
this.gridApi.mode = mode;
this.columnApi = params.columnApi;
this.gridApi.addDispatcher = this.props.add;
this.gridApi.deleteDispatcher = this.props.delete;
this.gridApi.updateDispatcher = this.props.update;
console.log(window.innerWidth);
this.sizeToFit();
window.onresize = () => {
this.gridApi.sizeColumnsToFit();
};
}
在onGridReady(params){...}它会工作,但会有延迟,并不是每个人的浏览器都以相同的速度运行。处理这个问题的任何范例?