Editor as native component
We provide a way to render native components as editor.
TIP
You can access close and save callbacks in properties. Check editor and EditorCtr
type for more.
tsx
// App.tsx
import { RevoGrid, Editor, type EditorType, type Editors } from '@revolist/react-datagrid';
/**
* Custom editor component
*/
const Button = ({ close } : EditorType) => {
return <button onClick={close}>Close</button>
};
function App() {
const MY_EDITOR = 'custom-editor';
const columns = [
{
prop: 'name',
name: 'First',
editor: MY_EDITOR,
},
];
const source = [
{
name: '1',
details: 'Item 1',
},
];
const gridEditors: Editors = { [MY_EDITOR]: Editor(Button) };
return (
<>
<RevoGrid columns={columns} source={source} editors={gridEditors} />
</>
)
}
export default App