Skip to content

Commit bdeb367

Browse files
author
Lukas Nys
committed
docs: add documentation on customizing row collapse
1 parent dac69c3 commit bdeb367

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{! BEGIN-SNIPPET docs-example-customizing-row-collapse.hbs }}
2+
<EmberTable as |t|>
3+
<t.head @columns={{this.columns}} />
4+
5+
<t.body
6+
@rows={{this.rows}}
7+
@onSelect={{action this.selectRows}}
8+
@selection={{this.selection}}
9+
as |b|
10+
>
11+
<b.row as |r|>
12+
<r.cell>
13+
<:collapse as |rowMeta onCollapseToggled|>
14+
<YourCustomButtonComponent
15+
@icon={{if rowMeta.isCollapsed "expand" "collapse"}}
16+
@onClick={{onCollapseToggled}}
17+
/>
18+
</:collapse>
19+
<:default as |value|>
20+
{{value}}
21+
</:default>
22+
</r.cell>
23+
</b.row>
24+
</t.body>
25+
</EmberTable>
26+
{{! END-SNIPPET }}

tests/dummy/app/templates/docs/guides/body/row-selection.md

+8
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ By default, Ember Table renders an input of type `checkbox` alongside an empty `
8989
{{demo.snippet name='docs-example-customizing-row-selection.hbs'}}
9090
{{/docs-demo}}
9191

92+
## Customizing Row Collapse
93+
94+
Similarly, you can customize the row collapse behavior by passing a named block `:collapse` to the `EmberTd` component. This block will receive `rowMeta` and the `onCollapseToggled` action as yielded arguments:
95+
96+
{{#docs-demo as |demo|}}
97+
{{demo.snippet name='docs-example-customizing-row-collapse.hbs'}}
98+
{{/docs-demo}}
99+
92100
## Aborting a Selection
93101

94102
Row selection follows a <a href="https://embermap.com/topics/component-side-effects/data-down-actions-up">DDAU</a> pattern, whereby the `onSelect` action handler supplied to Ember Table has control over which rows become selected. To ignore a user selection, it suffices to simply do nothing in the action handler.

0 commit comments

Comments
 (0)