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

there's a way to get rowData props passed to the property icon on actions?

Open snk-js opened this issue 6 years ago • 3 comments

In example, I have a button action in the action as a column, but I want this button rendered by the icon that it could receives state, that button has css properties that change due the state receiving in parameter. Or even disabled getting row props too, it would help so much

How could I access rowData inside the component I'm rendering in the icon property of actions?

actions={[ { disabled: (rowData) => {rowData.isDisabled} icon: (iWannaThisPropRowData)=> { return ( <NewUserButton onClick={null} prop = iWannaThisPropRowData.isActive/> )}, onClick: (e, rowData) => handleSetAddUser(rowData, setAddUserGroupRowIndex, setOffAddUserGroup) }, ] }

snk-js avatar May 25 '20 22:05 snk-js

You can pass a function as the action and access the rowdata like this: rowData => ({ icon: 'delete', tooltip: 'Delete User', onClick: (event, rowData) => confirm("You want to delete " + rowData.name), disabled: rowData.birthYear < 2000 })

DominikEngel avatar May 29 '20 07:05 DominikEngel

I didn't see the interface index, its able to receive a function that return Action. Tks

snk-js avatar May 29 '20 15:05 snk-js

I suggest admin to put a props on the function of property icon of interface Action

image

snk-js avatar May 29 '20 15:05 snk-js