Home > Blockchain >  I was looking for a solution to add Hyperlink in Material Data Grid
I was looking for a solution to add Hyperlink in Material Data Grid

Time:06-05

For example: refer this sample data grid.

I inserted Like this.

But was not able to make a link.

CodePudding user response:

Welcome to Stackoverflow @TangoCharlie

You need to use renderCell and not render:

  {
    field: "age",
    headerName: "Age",
    type: "number",
    width: 110,
    renderCell: (rowData) => (
      <Link href={`/user?id=${rowData.id}`} target="_blank">
        {rowData.row.age}
      </Link>
    )
  }

Sandbox: https://codesandbox.io/s/datagriddemo-material-demo-forked-93d5nc?file=/demo.js

CodePudding user response:

just return the string like this way...

`<a href="${params.getValue("id")}">${params.getValue("id")}</a>`
  • Related