Expandable Rows

April 28, 2026 · View on GitHub

Master/detail pattern — expand any row to reveal a custom Angular template below it.

Setup

@Component({
  template: `
    <ng-template #detail let-row>
      <div class="detail-panel">
        <h3>{{ row.name }}</h3>
        <p>Revenue: {{ row.revenue | currency }}</p>
      </div>
    </ng-template>

    <app-ui-grid [options]="gridOptions" />
  `
})
export class MyComponent {
  @ViewChild('detail') detailTemplate!: TemplateRef<any>;

  gridOptions: GridOptions = {
    id: 'master-detail',
    data: this.data,
    enableExpandable: true,
    expandableRowHeight: 120,
    expandableRowTemplate: this.detailTemplate,
    columnDefs: [
      { name: 'name' },
      { name: 'revenue', type: 'number' },
    ],
  };
}

Options

OptionTypeDefaultDescription
enableExpandablebooleanfalseEnable expandable rows
expandableRowHeightnumber150Min height of the detail row (px)
expandableRowTemplateTemplateRefAngular template for the detail content
expandableRowHeaderWidthnumberWidth of the expand toggle column
expandableRowScopeRecord<string, unknown>Extra variables injected into template context

Template Context

The template receives a GridExpandableTemplateContext:

PropertyTypeDescription
$implicitGridRecordThe row data (use with let-row)
rowGridRecordSame as $implicit
rowIndexnumberIndex of the row in the current view
expandedbooleanAlways true when the template renders

API

MethodDescription
gridApi.expandable.toggleRowExpansion(row)Toggle a single row
gridApi.expandable.expandAllRows()Expand all rows
gridApi.expandable.collapseAllRows()Collapse all rows
gridApi.expandable.toggleAllRows()Toggle all rows
gridApi.expandable.on.rowExpandedStateChanged(row, expanded) => void

Expandable vs Tree View

Expandable rows show custom template content below a data row (master/detail). Tree view shows child data rows that share the same column structure as parents. You can use both simultaneously.