我正在使用 ag-grid,我希望列宽根据网格内容是动态的,我通过使用以下方法来实现:
const onGridReady = params => {
params.columnApi.autoSizeAllColumns();
};
Run Code Online (Sandbox Code Playgroud)
但网格的宽度是固定的,我在网格的一侧有一个空间。(我也不能将宽度发送到网格,因为我不知道内容的大小是多少)我需要的是如何组合 autoSizeAllColumns 和 sizeColumnsToFit 函数。
我有一个使用react-select的组件,我从 props 中获取选项,在 selct 选项上我想用其他选项重新渲染选择 - 它有效,但 onChange 未触发。
import Select from 'react-select';
onChange(option){
dispatch(updateOptions());
}
render(){
return
<Select
options={this.props.options}
onChange={this.onChange}
value={this.state.text}
menuIsOpen
/>
}
Run Code Online (Sandbox Code Playgroud)