有谁知道如何从 Material-UI 获取所有行数据DataGrid?例如,我更改了DataGrid行内的一些值,并希望在更改后获取所有行。例子:
import { Button, TextField } from "@material-ui/core";
import { DataGrid } from "@material-ui/data-grid";
import moment from "moment";
const columns = [
{
field: "Col1",
headerName: "Col1",
flex: 1.0,
disableClickEventBubbling: true,
sortable: false,
disableColumnMenu: true
},
{
field: "Col2",
headerName: "Col2",
flex: 1.0,
disableClickEventBubbling: true,
sortable: false,
disableColumnMenu: true,
renderCell: (params) => (
<>
<TextField
type="date"
defaultValue={moment(Date.parse(params.row.Date)).format(
"YYYY-MM-DD"
)}
InputLabelProps={{
shrink: true
}}
/>
</>
)
},
{
field: "Col3",
headerName: "Col3",
flex: 1.0, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用react-sortable-hoc 使我的表行可拖动。但我无法让它正常工作,有人可以解释我做错了什么吗?我的例子:https ://codesandbox.io/s/vibrant-cherry-dtkl5?file=/src/App.js
我有一个DataGrid自定义单元格,当我单击单元格输入一些文本时,它会选择/取消选择一行。我可以以某种方式仅在单击复选框时设置选择吗?我尝试做这样的事情:
onCellClick={(params, events) => events.stopPropagation()}但没有帮助。我的例子:https ://codesandbox.io/s/serverless-moon-mg78zx?file=/src/App.js
我在不同的反应路由器路由上使用相同的组件。有谁知道如何在路线更改时卸载组件?现在,当我更改路线时,组件不会卸载,这是我的示例: https: //codesandbox.io/s/stupefied-cloud-bxfyf ?file=/src/MyComponent.js