如何为每一行添加可控制的复选框:MUI Datagrid中的实现方法
P粉329425839
P粉329425839 2024-03-29 08:47:07
[React讨论组]

我知道添加复选框或文本字段的方法是使用 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 (
    
      
    
  );
}

我尝试添加一个新的 ,其中包含诸如 之类的道具,但当然,这是行不通的。

P粉329425839
P粉329425839

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号