我知道添加复选框或文本字段的方法是使用 renderCell 并且它有效,我可以看到复选框:
但是,我不明白应该如何单独控制每一行的复选框/文本字段。例如,如果我希望第 1 行具有 TextField 的“填充”变体,而第 2 行具有“轮廓”变体,该怎么办?
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) => },
];
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 (
);
}
我尝试添加一个新的 ,其中包含诸如 之类的道具,但当然,这是行不通的。
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号