Skip to content

Commit c71cf34

Browse files
shleewhitedidoo
authored andcommitted
Website: AdvancedTable max height argument docs (#2872)
1 parent aaf3b5c commit c71cf34

File tree

3 files changed

+56
-65
lines changed

3 files changed

+56
-65
lines changed

website/app/styles/pages/components/advanced-table.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@
66
// COMPONENTS > TABLE > ADVANCEDTABLE
77

88
#show-content-components-table-advanced-table {
9-
.doc-advanced-table-scrollable-wrapper {
10-
overflow-x: auto;
11-
}
12-
13-
.doc-advanced-table-vertical-scrollable-wrapper {
14-
height: 500px;
15-
}
16-
179
.doc-advanced-table-multiselect-with-pagination-demo {
1810
.hds-advanced-table + .hds-pagination {
1911
margin-top: 16px;

website/docs/components/table/advanced-table/partials/code/component-api.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ The Advanced Table component itself is where most of the options will be applied
9292
Determines if even-numbered rows will have a different background color from odd-numbered rows.<br><br>
9393
**Important**: Advanced Table does **not** support setting `isStriped` to true when there are nested rows.
9494
</C.Property>
95-
<C.Property @name="hasStickyHeader" @type="boolean" @default="false">
96-
Determines if the Advanced Table has a sticky header.
95+
<C.Property @name="maxHeight" @type="string">
96+
Sets the maximum height of the Advanced Table. If the `@maxHeight` is set, there will automatically be a sticky header. To turn off the sticky header and still have a max height, set `@hasStickyHeader` to false.
97+
</C.Property>
98+
<C.Property @name="hasStickyHeader" @type="boolean">
99+
Determines if the Advanced Table has a sticky header. If set to `true`, must be used with the `@maxHeight` argument. If `@maxHeight` is set and `@hasStickyHeader` is `false`, there will not be a sticky header.
97100
</C.Property>
98101
<C.Property @name="hasStickyFirstColumn" @type="boolean" @default="false">
99102
Determines if the Advanced Table has a sticky first column.

website/docs/components/table/advanced-table/partials/code/how-to-use.md

Lines changed: 51 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ This component takes advantage of the `sort-by` helper provided by [@nullvoxpopu
153153

154154
!!!
155155

156-
Add `isSortable=true` to the hash for each column that should be sortable.
156+
Add `isSortable=true` to the hash for each column that should be sortable.
157157

158158
```handlebars
159159
<Hds::AdvancedTable
@@ -382,32 +382,31 @@ We recommend using functionalities like [pagination](/components/pagination), [s
382382

383383
#### Vertical scrolling
384384

385-
For situations where the default number of rows visible may be high, it can be difficult for users to track which column is which once they scroll. In this case, the `hasStickyHeader` argument can be used to make the column headers persist as the user scrolls.
385+
For situations where the default number of rows visible may be high, it can be difficult for users to track which column is which once they scroll. In this case, the `maxHeight` argument can be used to set the maximum height of the Advanced Table which will also add a sticky header. This will make the column headers persist as the user scrolls.
386+
387+
If you want to set the `maxHeight` but not have a sticky header, set `hasStickyHeader` to false.
386388

387389
```handlebars
388-
<!-- this is an element with "height: 500px" -->
389-
<div class="doc-advanced-table-vertical-scrollable-wrapper">
390-
<Hds::AdvancedTable
391-
@model={{this.demoDataWithLargeNumberOfRows}}
392-
@columns={{array
393-
(hash key="id" label="ID")
394-
(hash key="name" label="Name" isSortable=true)
395-
(hash key="email" label="Email")
396-
(hash key="role" label="Role" isSortable=true)
397-
}}
398-
@hasStickyHeader={{true}}
399-
@maxHeight="500px"
400-
>
401-
<:body as |B|>
402-
<B.Tr>
403-
<B.Td>{{B.data.id}}</B.Td>
404-
<B.Td>{{B.data.name}}</B.Td>
405-
<B.Td>{{B.data.email}}</B.Td>
406-
<B.Td>{{B.data.role}}</B.Td>
407-
</B.Tr>
408-
</:body>
409-
</Hds::AdvancedTable>
410-
</div>
390+
<Hds::AdvancedTable
391+
@model={{this.demoDataWithLargeNumberOfRows}}
392+
@columns={{array
393+
(hash key="id" label="ID")
394+
(hash key="name" label="Name" isSortable=true)
395+
(hash key="email" label="Email")
396+
(hash key="role" label="Role" isSortable=true)
397+
}}
398+
@hasStickyHeader={{true}}
399+
@maxHeight="500px"
400+
>
401+
<:body as |B|>
402+
<B.Tr>
403+
<B.Td>{{B.data.id}}</B.Td>
404+
<B.Td>{{B.data.name}}</B.Td>
405+
<B.Td>{{B.data.email}}</B.Td>
406+
<B.Td>{{B.data.role}}</B.Td>
407+
</B.Tr>
408+
</:body>
409+
</Hds::AdvancedTable>
411410
```
412411

413412
#### Horizontal scrolling
@@ -419,36 +418,33 @@ The component adds the sticky styles to the `[B].Th` component in each row. If t
419418
Note: Using `@hasStickyFirstColumn` with nested rows is not supported.
420419

421420
```handlebars
422-
<!-- this is an element with "overflow: auto" -->
423-
<div class="doc-advanced-table-scrollable-wrapper">
424-
<Hds::AdvancedTable
425-
@hasStickyFirstColumn={{true}}
426-
@model={{this.demoDataWithLargeNumberOfColumns}}
427-
@columns={{array
428-
(hash key="first_name" label="First Name" isSortable=true)
429-
(hash key="last_name" label="Last Name" isSortable=true)
430-
(hash key="age" label="Age" isSortable=true)
431-
(hash key="email" label="Email")
432-
(hash key="phone" label="Phone")
433-
(hash key="bio" label="Biography" width="350px")
434-
(hash key="education" label="Education Degree")
435-
(hash key="occupation" label="Occupation")
436-
}}
437-
>
438-
<:body as |B|>
439-
<B.Tr>
440-
<B.Th>{{B.data.first_name}}</B.Th>
441-
<B.Td>{{B.data.last_name}}</B.Td>
442-
<B.Td>{{B.data.age}}</B.Td>
443-
<B.Td>{{B.data.email}}</B.Td>
444-
<B.Td>{{B.data.phone}}</B.Td>
445-
<B.Td>{{B.data.bio}}</B.Td>
446-
<B.Td>{{B.data.education}}</B.Td>
447-
<B.Td>{{B.data.occupation}}</B.Td>
448-
</B.Tr>
449-
</:body>
450-
</Hds::AdvancedTable>
451-
</div>
421+
<Hds::AdvancedTable
422+
@hasStickyFirstColumn={{true}}
423+
@model={{this.demoDataWithLargeNumberOfColumns}}
424+
@columns={{array
425+
(hash key="first_name" label="First Name" isSortable=true)
426+
(hash key="last_name" label="Last Name" isSortable=true)
427+
(hash key="age" label="Age" isSortable=true)
428+
(hash key="email" label="Email")
429+
(hash key="phone" label="Phone")
430+
(hash key="bio" label="Biography" width="350px")
431+
(hash key="education" label="Education Degree")
432+
(hash key="occupation" label="Occupation")
433+
}}
434+
>
435+
<:body as |B|>
436+
<B.Tr>
437+
<B.Th>{{B.data.first_name}}</B.Th>
438+
<B.Td>{{B.data.last_name}}</B.Td>
439+
<B.Td>{{B.data.age}}</B.Td>
440+
<B.Td>{{B.data.email}}</B.Td>
441+
<B.Td>{{B.data.phone}}</B.Td>
442+
<B.Td>{{B.data.bio}}</B.Td>
443+
<B.Td>{{B.data.education}}</B.Td>
444+
<B.Td>{{B.data.occupation}}</B.Td>
445+
</B.Tr>
446+
</:body>
447+
</Hds::AdvancedTable>
452448
```
453449

454450
### Multi-select Advanced Table

0 commit comments

Comments
 (0)