Material-table: Turning on Selecton: true makes my custom action disappear.

Created on 13 Dec 2019  路  3Comments  路  Source: mbrn/material-table

Here's my code for reference.
I have a custom dropdown menu for one of my actions which disappears when I turn on the selection option. It seems like I have to choose one or the other. Can anyone help?

<MaterialTable title={<img src={cover} alt="Cover Logo" />} columns={columns} data={tasks} options={{ pageSizeOptions: [10, 50, 100, 500], pageSize: 10, actionsColumnIndex: 10, selection: true, showSelectAllCheckbox: false }} editable={{ onRowUpdate: (newData, oldData) => new Promise(resolve => { setTimeout(() => { console.log("onRowUpdate", newData, oldData); props.updateTasks(newData, oldData); resolve(); }, 600); }) }} onSelectionChange={row => { if (row.length > 0) { props.updateSelected(row[0].sid); } }} actions={[ rowData => ({ icon: () => <ActionMenu/> }) ]} components={{ Toolbar: props => ( <div> <MTableToolbar {...props} /> <div style={{ padding: "0px 10px" }}> <PitchForm color="primary" pitchType="pitch" /> </div> </div> ) }} />

Most helpful comment

actions={[
  rowData => ({
    icon: () => <ActionMenu/>
    position: 'row',
  })
]}

Add position: 'row', it should help

All 3 comments

actions={[
  rowData => ({
    icon: () => <ActionMenu/>
    position: 'row',
  })
]}

Add position: 'row', it should help

I faced really similar problem few hours ago. It may be helpful. In my case, passing the position field did not help, because I passed the actions as functions.

It took me few really long hours, but the problem was solved only when instead of array of function returning an object, I passed the objects directly. What i mean is:

actions={[
   {
       icon: () => <ActionMenu/>
       position: 'row',
   }
]}

Thanks guys. Much appreciated

Was this page helpful?
0 / 5 - 0 ratings

Related issues

slevy85 picture slevy85  路  3Comments

kfirshahar picture kfirshahar  路  3Comments

Mihier-Roy picture Mihier-Roy  路  3Comments

timrchavez picture timrchavez  路  3Comments

jlgreene2 picture jlgreene2  路  3Comments