[英]useRef to create a cellEditor in ag-grid in React
I have a questions on how to use the useRef Hook in React combined with the ag-grid component to create a persisent cellEditor.我有一个关于如何在 React 中使用 useRef Hook 结合 ag-grid 组件来创建持久化 cellEditor 的问题。 In the following Github example, there is an example on how to access the new value after the user has edited the field in the ag-grid:在下面的Github示例中,有一个关于如何在用户编辑 ag-grid 中的字段后访问新值的示例:
export default forwardRef((props, ref) => {
const inputRef = useRef();
useImperativeHandle(ref, () => {
return {
getValue: () => {
return inputRef.current.value;
}
};
});
useEffect(() => {
// https://github.com/facebook/react/issues/7835#issuecomment-395504863
setTimeout(() => inputRef.current.focus(), 10)
}, []);
return <input type="text" ref={inputRef} defaultValue={props.value}/>;
})
What I don't understand is how I can find out which row and field i am editing.我不明白的是如何找出我正在编辑的行和字段。 Could someone point me towards what I am missing?有人可以指出我缺少的东西吗?
The grid refresh api provides the interface for working with cells.网格刷新 api 提供了用于处理单元格的界面。 The props param has everything you need. props 参数有你需要的一切。
https://www.ag-grid.com/javascript-grid-refresh/#refresh-cells https://www.ag-grid.com/javascript-grid-refresh/#refresh-cells
interface RefreshCellsParams {
rowNodes?: RowNode[]; // specify rows, or all rows by default
columns?: (string|Column)[]; // specify columns, or all columns by default
force?: boolean; // skips change detection, refresh everything
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.