-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I create a custom link formatter? #135
Comments
@8483 have you tried this example? |
How do I make your example work in my case. I really have no idea. I am getting a Here's a CodeSandbox that demonstrates the problem. |
I got this reply on StackOverflow. react-tabulator https://github.com/ngduc/react-tabulator/blob/0.10.3/lib/Utils.js#L30 From source code,
rendering of a formatted element uses the A fix to react-tabulator needs to be done to support this use case. One way to go is to have |
@8483 I will look into this to see any alternative to ReactDOM.render |
Thank you for considering it! It really is a must have. |
Can we use portals for this instead? |
As of right now anytime you interact with the Table in a way that triggers reload (sorting by column for instance) it continually instantiates and appends a completely unique React instance to the DOM. Sort two or three times and all of a sudden your 10 rows with 2-3 custom ReactFormatted cells are now hundreds of mounted and abandoned React DOM/rendered instances. |
@8483 @ericnkatz will look into react dom & react-router. |
Cf. this react doc, shouldn't there be an "opposite" action of It's normal that |
I have created an implementation using portals in this gist. It's a Storybook pages. I'm using I don't know if it's OK to have thousands of portals. I.e. one per cell. Also, I didn't see any action do "dispose" a portal. I hope that disposing the DOM element where the portal was rendered suffices. Otherwise => memory leaks possible I think. |
Easy way is conditional rendering all page with tabulator const [redirect, setRedirect] = useState({ allow: false })
const columns = [
{ title: 'No', field: 'no', },
{
title: 'Patient', field: 'patient', cellClick: function (e, cell) {
const rowInfo = cell._cell.row.data
setRedirect({ allow: true, id: rowInfo.id }) //here we update state
}
},
]
//....
if (redirect.allow) {
return <Redirect to={{
pathname: '/accounts/profile',
state: {
id: redirect?.id
}
}} />
} else {
//...
} |
I cannot for the life of me get the formatter to work.
I get blank cells instead of a formatted link.
The React documentation could really use some explanations.
Side-question: Can I use the vanilla Tabulator in React, instead of the adapted one?
This way works, but it beats the purpose, as it reloads everything.
I'd like to learn how to use custom formatters.
The text was updated successfully, but these errors were encountered: