-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add example of a mat-table with re-orderable columns #18456
Conversation
src/components-examples/material/table/table-reorderable/table-reorderable-example.ts
Outdated
Show resolved
Hide resolved
src/components-examples/material/table/table-reorderable/table-reorderable-example.ts
Outdated
Show resolved
Hide resolved
Refactored to not have the hack now that the fix is in. Also cleaned lint errors. PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
src/components-examples/material/table/table-reorderable/table-reorderable-example.ts
Outdated
Show resolved
Hide resolved
@jadekler could you go into more detail on the version of angular required? |
@Falven I've updated my PR description, but basically it's HEAD currently. Hopefully those bug fixes are released soon. |
@jadekler FYI to show up on the docs site, we also need to add this entry to https://github.com/angular/material.angular.io/blob/master/src/app/shared/documentation-items/documentation-items.ts#L410 |
|
(cherry picked from commit 7b3ea26)
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This adds an example of how to re-order a table's columns with CDK drag drop.
This example can be seen at https://stackblitz.com/edit/mat-table-col-reorder. (I created that - it is almost 1:1) (It does not work since stackblitz doesn't have the fix for #15948)
This has come up numerous times in issues and requests:
(etc)
Note: It looks like CdkDragDrop.previousIndex is never being updated. It always reports the original index - rather than the previous - of the thing being dragged. So, in this PR I've had to add a little mapping from CdkDragDrop.previousIndex -> name from column list -> actual previousIndex.Note: This requires a very recent version of angular that has the fix for #15948 and #18482 (as of writing, that is likely to be
HEAD
- hopefully fixes are released soon).