admin管理员组

文章数量:1332879

I am working in a react project and i am using Data Grid. There are several fields on that grid , the filter is working good with the other fields but not working with the field that use renderCell. Is there any way to filter the movie title? here is the code :

 const columns = [
{ field: "_id", headerName: "ID", width: 110 },
{
  field: "movie",
  headerName: "Movie",
  width: 240,

  renderCell: (params) => {
    return (
      <div className={Style.usercell}>
        <img src={params.row.featuredImg} alt="" />
        <span>{params.row.title}</span>
      </div>
    );
  },
},
{ field: "genre", headerName: "Genre", width:  120 },
{ field: "year", headerName: "Year", width:  120 } ]

I am working in a react project and i am using Data Grid. There are several fields on that grid , the filter is working good with the other fields but not working with the field that use renderCell. Is there any way to filter the movie title? here is the code :

 const columns = [
{ field: "_id", headerName: "ID", width: 110 },
{
  field: "movie",
  headerName: "Movie",
  width: 240,

  renderCell: (params) => {
    return (
      <div className={Style.usercell}>
        <img src={params.row.featuredImg} alt="" />
        <span>{params.row.title}</span>
      </div>
    );
  },
},
{ field: "genre", headerName: "Genre", width:  120 },
{ field: "year", headerName: "Year", width:  120 } ]
Share Improve this question asked Aug 28, 2021 at 6:05 Relex ModeRelex Mode 392 silver badges4 bronze badges 1
  • possible duplicate of: stackoverflow./questions/68550751/… – Jeff Commented Nov 16, 2021 at 18:55
Add a ment  | 

1 Answer 1

Reset to default 8

Add this:

  renderCell: (params) => {
    return (
      <div className={Style.usercell}>
        <img src={params.row.featuredImg} alt="" />
        <span>{params.row.title}</span>
      </div>
    );
  },
  valueGetter: (params) => params.row.title

本文标签: javascriptMaterial UI data grid filter not working when using renderCell in a fieldStack Overflow