Grid: Hide DetailTemplate

1 Answer 203 Views
Grid
Hendrik
Top achievements
Rank 1
Iron
Iron
Iron
Hendrik asked on 14 May 2023, 08:58 AM

I just discovered the DetailTemplate and it is great. But I build myself a genereric Grid-Control with the Tererik-Grid and I pass a RenderFragement from my Parent-Component to this Control. This works perfectly. But even if the RenderFragemt is Null, the "+" and "-" Buttons to expand and collaps the DetailTemplate are always shown. How can I hide them ?

Unfortunately this is not working:

    @if (ChildContent != null)
    <DetailTemplate>
        {
            @ChildContent
        }
    </DetailTemplate>
    }

1 Answer, 1 is accepted

Sort by
0
Accepted
Nadezhda Tacheva
Telerik team
answered on 17 May 2023, 08:48 AM

Hi Hendrik,

You can handle the OnRowRender event of the Grid to evaluate whether the current row has children. Based on that, you can then apply a conditional CSS class to hide the expand icon for the specific row.

You can find some more details and an example in this article: Conditionally Hide Hierarchical Grid Expand Button.

I hope you will find that useful. Please let us know if any other questions appear.

Regards,
Nadezhda Tacheva
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Hendrik
Top achievements
Rank 1
Iron
Iron
Iron
commented on 17 May 2023, 09:25 AM

Hello Nadeszhda,

thank you very much for your time and effort. In your solution is just the icon conditionally hidden but the whole column still exists. I need to either show or hide the "Details"-Column. But I think, the way is not too far anymore....

 

Nadezhda Tacheva
Telerik team
commented on 19 May 2023, 01:59 PM

Hi Hendrik,

Indeed, the solution I shared is focused on hiding the expand icons for the Grid records that do not have children.

Based on your additional description, I understand that you need to hide the whole column that contains these icons (I suppose this is for the generic purposes of the component).

If so, you may check this article for more details and an example: https://docs.telerik.com/blazor-ui/knowledge-base/grid-conditional-toolbar-detail-template.

Testing the snippet from it on my end, it looks like both the Detail Template and the Details Column are successfully hidden.

Take your time to revise and test the approach on your end and please let me know if you are still experiencing any issues. If so, please send an isolated runnable sample reproducing the behavior you are getting, so I can debug it and suggest how to move forward.

Thank you in advance!

Hendrik
Top achievements
Rank 1
Iron
Iron
Iron
commented on 19 May 2023, 02:44 PM

Hello Nadeszhda,

thank you so much. That works perfectly and I learned some new tricks generally !

 

Tags
Grid
Asked by
Hendrik
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Nadezhda Tacheva
Telerik team
Share this question
or