首先,向服务器请求一些数据。然后我想添加一些数据。数据值中没有ID,但表单需要显示序列号。
const columns: GridColDef[] = [
{
field: 'id' ,
headerName: 'number',
filterable: false,
renderCell:(index:any) => `${index + 1}`
},
{ field: 'code' , headerName: ' code' },
{ field: 'type' , headerName: ' type' },
]
Run Code Online (Sandbox Code Playgroud)
<DataGrid rows={row} columns={columns} />
Run Code Online (Sandbox Code Playgroud)
但索引是Nan。当我添加新数据时,如何在表中的每一行生成序号?