How to conditionally disable grid master-detail expansion on a row-by-row basis

1 Answer 30 Views
Grid
Bill
Top achievements
Rank 2
Iron
Bill asked on 27 Feb 2025, 11:18 PM
Using the Angular grid with a detail template for master-detail functionality, how can I disable the functionality and hide the plus sign on rows which have no child data to display?  I found a feature request from 2016 here: https://github.com/telerik/kendo-angular/issues/106 , but it does not appear to have been implemented as described given errors I get in the console.

1 Answer, 1 is accepted

Sort by
0
Accepted
Hetali
Telerik team
answered on 03 Mar 2025, 08:24 PM

Hi Bill,

Thank you for reaching out.

We have a dedicated example for Conditional Display in the Master-Detail Grid. In order to hide the detail row and the expand/collapse button when there is no child data to display, use the kendoGridDetailTemplateShowIf property as seen below:

<kendo-grid [data]="data" [selectable]="true">
  <kendo-grid-column field="ProductName"></kendo-grid-column>
  <ng-template
    kendoGridDetailTemplate
    let-dataItem
    [kendoGridDetailTemplateShowIf]="showOnlyContinuedDetails"
  >
    <p>Discontinued: {{ dataItem.Discontinued}}</p>
  </ng-template>
</kendo-grid>
public showOnlyContinuedDetails(dataItem: Product): boolean {
  return !dataItem.Discontinued;
}

Output:

In this StackBlitz example, the detail row and the expand/collapse button are hidden based on the condition. This condition can be modified in a way where it can hide the detail row if no child data is available.

I hope this helps. Please let me know if I can further assist you.

Regards,
Hetali
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

Tags
Grid
Asked by
Bill
Top achievements
Rank 2
Iron
Answers by
Hetali
Telerik team
Share this question
or