You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.13 17:57:57