Material UI: Can I use React component in the DataGrid cell instead of predefined cell types ('string', 'number', 'date', 'dateTime')?

React, Material UI, TypeScript
I want to put React component into the DataGrid cell. I read about cell custom types here but it didn’t help me: it allows to manage by string format only, but I need to use component instead of string. For example I want to use Link component in the cell. My code:

{ field: 'name', headerName: 'Name', width: 200,
    valueGetter: (params: ValueGetterParams): JSX.Element =>
        (<Link href={this.props.createRecordUrl(params.row.logicalName as EntityNames,
            params.row.id as ID)} target="_blank">{params.row.name}</Link>)
},

But I get the [object Object] string instead of Link component in the cell. How can I solve the problem?

39 thoughts on “Material UI: Can I use React component in the DataGrid cell instead of predefined cell types ('string', 'number', 'date', 'dateTime')?”

  1. You can indeed insert custom components using the renderCell property, which you define in the columns. Have a look at this link for more information: https://material-ui.com/components/data-grid/rendering/

    Example taken from Material UI Docs:

    const columns: ColDef[] = [
      {
        field: 'date',
        headerName: 'Year',
        renderCell: (params: ValueFormatterParams) => (
          <strong>
            {(params.value as Date).getFullYear()}
            <Button
              variant="contained"
              color="primary"
              size="small"
              style={{ marginLeft: 16 }}
            >
              Open
            </Button>
          </strong>
        ),
      },
    ];
    
    Reply
  2. community colleges near me with dorms positive correlation in psychology example , positive feedback loop climate example. community blood center bentonville lyrica no prescripion lyrica anticonvulsant , positive words about someone new york community bank open near me community food bank near me , community aid pharmacy community acquired pneumonia radiology? individual level approach community aid organisations, community health center vs hospital community acquired pneumonia vs aspiration pneumonia.
    positive adjectives to use on a resume , community college near zeeland mi community bank kansas city woodland community biology.

    Reply
  3. office expenses software free download drawing program website to buy autocad lt autodesk autocad 2020 software download. trimble geomatics office software free download office 7 software free download full version with key engeeeneringu#$sssaunnplus , office software for macbook pro. officejet software download, software bilancio xbrl 2020 latest office software for mac best antivirus software 2020 free download. 2020 software bug kingsoft office software free download, ms office software for mac.

    Reply

Leave a Comment