I know the way to add a checkbox or text field is to use renderCell and it works, I can see the checkbox:
However, I don't understand how I should control each row's checkbox/textfield individually. For example, what if I want row 1 to have the "fill" variant of the TextField, and row 2 to have the "outline" variant?
import * as React from "react"; import {DataGrid} from "@mui/x-data-grid"; import {Box, Checkbox, TextField} from "@mui/material"; const columns = [ {field: "id", headerName: "ID", width: 30}, {field: "col1", headerName: "Column 1", width: 150}, {field: "col2", headerName: "Column 2", width: 150}, {field: "col3", headerName: "Column 3", width: 150, renderCell: (params) => <Checkbox />}, ]; const rows = [ {id: 1, col1: "Example", col2: "Content", col3: ??????}, {id: 2, col1: "Example", col2: "Content", col3: ??????}, {id: 3, col1: "Example", col2: "Content", col3: ??????}, ]; export default function Table() { return ( <Box sx={{}}> <DataGrid rows={rows} columns={columns} /> </Box> ); }
I tried adding a new <Checkbox />
with props like <Checkbox defaultChecked/>
but of course, that didn't work of.
Please take a look at the example I provided for you. Hope I can answer your question. https://codesandbox.io/s/optimistic-leaf-xm32lk ?file=/Demo.tsx