Material-table: Link as cell data

Created on 17 Apr 2019  路  9Comments  路  Source: mbrn/material-table

In our requirement, we have to display list of titles in one of the column. Each title should be a link and on hover over we need to display modal which display details about each title. How can i achieve this ?

help wanted

Most helpful comment

Nevermind figured it out via disableClick: true on the column!

All 9 comments

Hi @jatinvmehta ,

I think that you can use custom render feature to achive this case. Look at example.

https://mbrn.github.io/material-table/#/docz-examples-07-example-custom-render

If it works, why you dont ask this question on Stackoverflow with material-table tag? This would be helpful for other developers :)

Will try that. Can i put any component inside that render method ? like link or button

Of course. It gives you rowdata and expect a component to draw

@mbrn In case of using Link (or custom React component), grouping doesn't work.

I will find a solution to this case @revskill10

@mbrn

Instead of avatar like the example if we hook a component inside with a onClick or onChange function? How do we stop the propagation if we utilize a onRowClick on the <MaterialTable /> component? Both events are triggering.. I tried deep diving into the code base and it looks like I can add a onClick to the Cell component but I only want to do it only on ONE column

Example: (custom render checkbox)

      columns: [
        {
          field: 'check',
          editable: 'never',
          cellStyle: {
            padding: 'inherit',
            width: '5%',
          },
          render: data => (
            <Checkbox
              disabled={data && data.tableData.editing === 'update'}
              checked={_.get(data, 'check', false)}
              value={_.get(data, 'check', false)}
              onChange={e => this.handleChange(e, data.tableData.id)} //deals with check mark
            />
          )
        },

demo

Nevermind figured it out via disableClick: true on the column!

I will find a solution to this case @revskill10

Have you found a solution for this @mbrn ?

Was this page helpful?
0 / 5 - 0 ratings