-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
feat(table): support native table selectors #10594
Conversation
7acb55d
to
da35122
Compare
da35122
to
610e357
Compare
src/cdk/table/table.ts
Outdated
} | ||
} | ||
|
||
ngOnInit() { | ||
if (this._elementRef.nativeElement.tagName === 'TABLE') { |
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.
Prefer nodeName
to tagName
src/cdk/table/table.ts
Outdated
/** Adds native table sections (e.g. tbody) and moves the row placeholders into them. */ | ||
private _applyNativeTableSections() { | ||
const tHeadEl = document.createElement('thead'); | ||
const tBodyEl = document.createElement('tbody'); |
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.
Just thead
and tbody
since that's the tag name; it's weird as camelCase
src/lib/table/table.md
Outdated
@@ -278,3 +278,50 @@ Table's default role is `grid`, and it can be changed to `treegrid` through `rol | |||
|
|||
`mat-table` does not manage any focus/keyboard interaction on its own. Users can add desired | |||
focus/keyboard interactions in their application. | |||
|
|||
### Using flex layout |
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.
Reword this to be something like Tables with `display: flex
so that it's not confused with @angular/flex-layout
src/lib/table/table.md
Outdated
### Using flex layout | ||
|
||
The `MatTable` does not require that you use a native HTML table. Instead, you can use an | ||
alternative approach that uses flex-layout for the table's styles. |
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.
display: flex
Thanks - updated with the comments applied |
Can you please give us a stackblitz example for this. Having difficulty to implement native table with rowspan as a material table. Sample code is also more then enough. Thanks in advance. |
@jainankit102 check material.angular.io. it's all there. |
@CDDelta thanks for that but I already checked in material.angular.io. didn't found any example regarding material table with rowspan and colspan. Thanks |
@jainankit102 sorry it was early in the morning, I didn't notice you were looking for rowspan examples. I recommend you open a new issue about this, you would be more likely to get responses. |
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. |
Summary:
Add native table selectors to the
CdkTable
(e.g.<table cdk-table>
) and refocuses the docs on this approach as the primary way of using the table componentsFixes #6058, #7964, #9027, #8680
Closes #5888, #5866
Full Description:
Add the ability to render the table using the native HTML table element as opposed to using the flex-based
<mat-table>
element. This quickly enables key features such as auto column resizing, col/row span, easy copy/paste (cells map into spreadsheets easily). Also, any native table can become a material table by simply applying themat-table
class (+ classes to rows/cells).Benefits to using native table:
<table>
)CdkTable
supports a table appearance out of the box (no need for additional styling)