-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
DataTable: Unable to use Custom Columns when has Dynamic Columns rendering #6028
Comments
@gabrielo91 this is not supported because Columns are not components that render themselves: #2052 (comment) This has been asked about many times in the past: #2268 |
@melloware Thank you in advance for clarifying my concerns. I'm trying to understand the concept that "Columns are not components that render themselves." After reviewing the issues, I'm still a bit confused about the practical implications of this. Specifically, I have a few questions:
Could you please provide some guidance on these points?
|
isnt the answer right here: https://primereact.org/datatable/#dynamic_columns You create a JSON object that has all the dynamic column properties including const columns = [
{ field: 'code', header: 'Code', filterElement: <YourFilter /> }, |
@melloware Ok, you have solved it, we didn't know that the object you pass to render columns supported the Thanks very much for your help |
Yep ANY property on the column can be in your dynamic JSON. |
Describe the bug
I'm trying to use the DataTable component with dynamic columns, just like the docs explain here, I have used the following code. As you can see I have created a component called
SpecialColumn
which should render each column, however, I noticed that this component is not being used at all, I noticed that my changes were not applied or even that athrow new Error
did not break the app. Is this behavior expected? how can I overwrite the default behavior and use my custom element to render the columns?The code can be tested and edited in this sandbox
Reproducer
https://stackblitz.com/edit/wapju4?file=src%2FApp.jsx
PrimeReact version
10.5.1
React version
18.x
Language
TypeScript
Build / Runtime
Create React App (CRA)
Browser(s)
No response
Steps to reproduce the behavior
Expected behavior
The app should use the
SpecialColumn
componentThe text was updated successfully, but these errors were encountered: