使用MUI DataGrid时valueGetter中params为undefined但renderCell正常的问题求助
使用MUI DataGrid时valueGetter中params为undefined但renderCell正常的问题求助
我现在在MUI DataGrid里遇到个头疼的问题:想根据行内其他列的值来设置当前列的取值,在renderCell里这么写完全能正常工作,但把同样的逻辑移到valueGetter里时,传入的params居然是undefined!有没有大佬能教教我,怎么在valueGetter里访问到当前行的其他值啊?
简化后的示例代码
renderCell: (params: GridCellParams) => { const today = new Date(); if (Date.parse(params.row.effectiveStartDateEst) > today){ return <Chip label='Inactive'/> } else{ return <Chip label='Active' color='success' /> } }, valueGetter: (params: GridCellParams) => { const today = new Date(); if (Date.parse(params.row.effectiveStartDateEst) > today){ return 'Inactive' } else{ return 'Active' } }
上面这段代码在renderCell里运行完全正常,但在valueGetter里就会因为params是undefined而报错,实在搞不懂哪里出问题了😭
备注:内容来源于stack exchange,提问作者JWillis
相关产品推荐
相关产品推荐

