tleunen / react-mdl

React Components for Material Design Lite
https://tleunen.github.io/react-mdl/
MIT License
1.76k stars 255 forks source link

[DataTable] Render <Link> from React-Router inside DataTable cell #337

Closed xdvarpunen closed 8 years ago

xdvarpunen commented 8 years ago

Hi,

Is there way to render Link inside DataTable cell? So far I tried this:

data.map(function(row){
  // set Link element as string for render it in DataTable cell
  row["edit"] = `<Link to="/edit">Edit</Link>`;
  return row}))

Thanks, XDVarpunen

Brickpsp commented 8 years ago

you can try my way:

<DataTable
    shadow={0}
    rows={yourdata}>
<TableHeader name="link" cellFormatter={(link) => <a href={link}>{link}</a>}  tooltip="This is link">Link</TableHeader>
</DataTable>
tleunen commented 8 years ago

Yes, @Brickpsp is right, you can use the cellFormatter to format the content the way you want :-)

I'm closing this ticket, let me know if you still have troubles with this feature.