material-table icon indicating copy to clipboard operation
material-table copied to clipboard

Add new row in editable mode when clicking on custom button or icon

Open anuj47billion opened this issue 6 years ago • 5 comments

Hello All, I need to add new row editable mode on click the custom icon which was created by actions props like

actions={[ { icon: () => , tooltip: 'Copy', onClick: (event, rowData) => { //Functionality } } ]}

IS there any possibity to do this?

anuj47billion avatar Dec 12 '19 07:12 anuj47billion

I tried to achieve this by doing the following:

actions={[
     {
          icon: tableIcons.FileCopy,
          tooltip: 'Copy',
          onClick: (event, rowData) => {
               tableRef.current.props.editable.onRowAdd(rowData)
           },
        },
  ]}               

However, ran into error of Uncaught TypeError: Cannot read property 'editing' of undefined

MeghaBambra avatar Jan 09 '20 17:01 MeghaBambra

Running into the same question -- need to use the standard mat-ui floating add icon. (The circle with the plus sign.) @MeghaBambra Did you figure this out?

thelazydogsback avatar Jan 10 '20 01:01 thelazydogsback

So I got this working with the following:

actions={[
                    {
                      icon: tableIcons.FileCopy,
                      tooltip: 'Copy',
                      onClick: (event, rowData) => {
                        const newData = {...rowData, uuid: uuid() }
                        tableRef.current.props.editable.onRowAdd(newData)
                      },
                    },
                  ]}

You cannot pass rowData as it was cause an error - guessing because its modifying existing data structure table is bound to. So i created a copy of it.

This however just simply copies an existing row and adds a new row without being in editable mode. I'm guessing you'll I've to dig through the props and see if that option is exposed.

MeghaBambra avatar Jan 14 '20 18:01 MeghaBambra

anyupdates on this one?

didopop3 avatar Mar 10 '20 23:03 didopop3

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.

stale[bot] avatar Jul 05 '20 19:07 stale[bot]