Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e297c8a
test: Add a failing test showing the reorder problem
vitch May 17, 2023
f3e53b3
test: Update test because we can and should retain the position of hi…
vitch May 17, 2023
6b6d702
demo: Add an extra column to the demo
vitch May 17, 2023
9fc3db3
feat: Implement more intuitive column sorting
vitch May 17, 2023
e750726
chore: Fix column ordering demo
vitch May 23, 2023
7e03df0
feat: Explicitly add any missing columns to the end of the list
vitch May 30, 2023
68c30a5
fix: Remove any extra columns from the passed in map
vitch May 30, 2023
3139ad6
test: Add a test trying to hit `removeExtraColumnsFromMap`
vitch May 30, 2023
41811bb
chore: Ensure consecutive zero based positions when initialised
vitch Jul 4, 2023
812c6ef
test: Add a failing test showing the reorder problem
vitch May 17, 2023
6d1e816
test: Update test because we can and should retain the position of hi…
vitch May 17, 2023
a999929
demo: Add an extra column to the demo
vitch May 17, 2023
9854e3b
feat: Implement more intuitive column sorting
vitch May 17, 2023
ff393d2
chore: Fix column ordering demo
vitch May 23, 2023
a02d3ba
feat: Explicitly add any missing columns to the end of the list
vitch May 30, 2023
66e7a60
fix: Remove any extra columns from the passed in map
vitch May 30, 2023
53c1610
test: Add a test trying to hit `removeExtraColumnsFromMap`
vitch May 30, 2023
fb83848
chore: Ensure consecutive zero based positions when initialised
vitch Jul 4, 2023
af9dc69
Merge branch 'reordering-hidden-columns' of https://github.com/CrowdS…
johanrd Apr 11, 2025
1d24d8d
cleanup
johanrd Apr 11, 2025
a87ffce
cleanuo
johanrd Apr 11, 2025
3cd3895
Merge branch 'main' into reordering-hidden-columns
johanrd Aug 25, 2025
da117aa
Merge branch 'main' into reordering-hidden-columns
johanrd Aug 25, 2025
c8c7091
Fix column reordering crash when column set changes between deploymen…
johanrd Oct 3, 2025
df44993
review comment
johanrd Oct 3, 2025
ff21ce2
address review comments, + be more resilient towards missing/added co…
johanrd Oct 3, 2025
ce1d44e
// Add any missing columns to the end
johanrd Oct 3, 2025
8c36696
lint
johanrd Oct 3, 2025
feb5a9f
revert api of ColumnOrder to be non-breaking, and rename availableCol…
johanrd Oct 3, 2025
746dc57
lint
johanrd Oct 3, 2025
9c00a1f
lint
johanrd Oct 3, 2025
c5dc334
lint
johanrd Oct 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs-app/public/docs/1-get-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export default class extends Component {
key: "C",
pluginOptions: [ColumnResizing.forColumn(() => ({ minWidth: 200 }))],
},
{
name: "column D",
key: "D",
pluginOptions: [ColumnResizing.forColumn(() => ({ minWidth: 200 }))],
},
],
data: () => this.data,
plugins: [
Expand Down
89 changes: 89 additions & 0 deletions docs-app/public/docs/2-plugins/column-visibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,92 @@ but the important things to make sure exist are:
- buttons are focusable
- buttons can be navigated to and pressed via keyboard
- buttons can be navigated to and pressed via screen reader tool

## Combining with Column Reordering

When using both `ColumnVisibility` and `ColumnReordering` together, the reordering automatically skips over hidden columns when moving left/right.

<div class="featured-demo" data-demo-fit data-demo-tight>

```gjs live preview no-shadow
import Component from "@glimmer/component";
import { on } from "@ember/modifier";
import { fn } from "@ember/helper";

import { headlessTable } from "@universal-ember/table";
import { meta, columns } from "@universal-ember/table/plugins";
import {
ColumnVisibility,
hide,
show,
} from "@universal-ember/table/plugins/column-visibility";
import { ColumnReordering } from "@universal-ember/table/plugins/column-reordering";

import { DATA } from "docs-app/sample-data";

export default class extends Component {
table = headlessTable(this, {
columns: () => [
{ name: "column A", key: "A" },
{ name: "column B", key: "B" },
{ name: "column C", key: "C" },
{ name: "column D", key: "D" },
],
data: () => DATA,
plugins: [ColumnVisibility, ColumnReordering],
});

get columns() {
return columns.for(this.table);
}

<template>
<div class="flex flex-wrap gap-x-4 gap-y-2 mb-4">
{{#each this.table.columns as |column|}}
{{#let (meta column) as |m|}}
<div class="flex gap-2 items-center">
<span>{{column.name}}:</span>
<button {{on "click" (fn hide column)}}>Hide</button>
<button {{on "click" (fn show column)}}>Show</button>
<button {{on "click" m.ColumnReordering.moveLeft}}>⇦</button>
<button {{on "click" m.ColumnReordering.moveRight}}>⇨</button>
</div>
{{/let}}
{{/each}}
</div>
<div class="h-full overflow-auto" {{this.table.modifiers.container}}>
<table>
<thead>
<tr>
{{#each this.columns as |column|}}
<th
{{this.table.modifiers.columnHeader column}}
class="relative group"
>
{{column.name}}
</th>
{{else}}
<th>
No columns are visible
</th>
{{/each}}
</tr>
</thead>
<tbody>
{{#each this.table.rows as |row|}}
<tr>
{{#each this.columns as |column|}}
<td>
{{column.getValueForRow row}}
</td>
{{/each}}
</tr>
{{/each}}
</tbody>
</table>
</div>
</template>
}
```

</div>
12 changes: 12 additions & 0 deletions docs-app/public/docs/3-demos/external-column-ordering.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,21 @@ export default class extends Component {
@tracked pendingColumnOrder;

changeColumnOrder = () => {
// Basic usage (backwards compatible):
// Pass your columns and they're all treated as visible
this.pendingColumnOrder = new ColumnOrder({
columns: () => this.columns,
});

// Advanced usage (with ColumnVisibility plugin):
// Pass ALL columns and provide a visibleColumns map
// this.pendingColumnOrder = new ColumnOrder({
// columns: () => this.table.columns.values(), // All columns (including hidden)
// visibleColumns: () => this.columns.reduce((acc, col) => {
// acc[col.key] = meta(col).ColumnVisibility?.isVisible !== false;
// return acc;
// }, {}),
// });
}

handleReconfigure = () => {
Expand Down
Loading
Loading