Conditionally Rendering Nested Column

1 Answer 111 Views
Grid
Janki
Top achievements
Rank 4
Bronze
Iron
Iron
Janki asked on 22 Mar 2023, 07:40 PM

When I try to conditionally render a column that's nested, its value cells don't show up (which is correct), but its header cell still shows up (which is incorrect), making the entire header row misaligned with the grid rows -- see example below:

https://codesandbox.io/s/new-https-mt0knv?file=/app/main.jsx

 

Is there any workaround for this? I've tried cellRender, rowRender, headerCell, and headerClassName to no avail, but maybe I've missed something. Unfortunately, I cannot use CSS display:none on the ".k-header" selector because I have a grouped grid where I need that first column header for the hierarchy, and I'd like to try anything but CSS for this as this seems like a KendoReact (JS) bug in general.

Janki
Top achievements
Rank 4
Bronze
Iron
Iron
commented on 22 Mar 2023, 08:00 PM | edited

If I do width="0px", it works for the UI render and the PDF Export but not the Excel Export 

1 Answer, 1 is accepted

Sort by
0
Accepted
Konstantin Dikov
Telerik team
answered on 23 Mar 2023, 12:33 PM

Hello Janki,

For dynamically changing the columns structure of the Grid you can use an external collection with the columns configuration and add for example a "show" property that can be used for filtering the columns. Following is an example demonstrating such approach:

Hope this helps.

 

Regards,
Konstantin Dikov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Janki
Top achievements
Rank 4
Bronze
Iron
Iron
commented on 23 Mar 2023, 03:25 PM

Thank you, Konstantin! I ended up filtering out the columns further up the chain (right after the fetch call) instead of filtering on the fly within the render. I think both solutions do the job, hoping this helps others who run into this issue! 
Tags
Grid
Asked by
Janki
Top achievements
Rank 4
Bronze
Iron
Iron
Answers by
Konstantin Dikov
Telerik team
Share this question
or