-
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
[Table] Add ability to expand rows on interaction #6095
Comments
See #5936 Please keep GitHub issues for bug reports / feature requests. Better avenues for troubleshooting / questions are stack overflow, gitter, mailing list, etc. |
Hi Andrew, Thank you for adding this as feature. May i know when the feature will be available ? |
This will be a lower priority feature that we'll need to incorporate after we've worked on features such as virtual repeat and sticky rows/columns to make sure that it's able to work alongside these higher priority features. |
99% of applications need this feature so I cannot understand why this is a lower priority :( |
Virtual repeat and sticky rows/columns are a much higher priority than expanding rows and should be implemented first before bringing in this feature. It's likely that you will be able to create some kind of expanding row UX when rows can be conditionally displayed using the |
Ok since I am planning a new project and I need to know dates can you give an approximation of when this is gonna be implemented please? Hope you understand. Thanks |
@irowbin I know it takes time and that the guys are doing their best. And you can see that from the great result they achieved so far. |
Instead of expanding rows if we can click on a button in the row and go to an item details view, modal or form, that would be good enough for now. I just started trying to figure this out a few minutes ago and found this active conversation with a Google search. I'm not sure if this is possible, my skills are "limited', but something like this. I have a click event in a button in a row. I need to grab the member.$key, which does display in the second column below with my data, but I haven't figured out how to get the $key (Firebase key) in the click param 'member' yet. Using member.$key and row.$key as a param doesn't work.
|
Thanks for the suggestion Jim.. But here data is represented in the form of rows. So on click of particular row data the view should open. For that there should be some link provided between row data and row detail which is not supported in the current package at this moment. |
KendoUI widgets are implemented in angular (no jQuery wrapper).. KendoUI angular datagrid master/details I am also looking at alternative to material datagrid since it is not polished and ready for real projects (no choice). My project can't wait for material 2 implementations of mater/detail and neither team will venture into developing widgets (no resource to do it) |
@vibingopal It seems that the row is an object and that there should be some JS way of capturing it and sending the whole data object back to the component code to be parsed there. Is there a row identifier that could be captured somehow. Master/detail is a biggee and it would be nice to figure out a hack until a more elegant solution is provided. |
I found another cool open-source UI Platform from Teradata that is built on Angular & Angular Material (Design). It is pretty much material 2 next version. They're not implementing master/detail because material 2 has not included in road-map. |
For the AM2 Data Table as master - detail I posted my code here: Easy solution. It isn't the drop-down solution that some posters above have requested. |
I've added expand/collapse row by following an example from here https://plnkr.co/edit/ZL6OnWwVmOCPYetp96XX?p=preview However I am still unable to freeze columns from left/right while horizontal scroll. For instance here is my snapshot. |
@svstartuplab Since the expandable rows feature is on the backburner I had to implement a modal on row click that does just that, I pass the user's id to my modal and have an API call to get the detailed infos show up in the modal. |
@Lakston @irowbin Please add your solutions to my Stack Overflow post at https://stackoverflow.com/questions/45402690/how-to-setup-angular-material-2-data-table-setup-as-master-detail. Nice to collect them on one place that everyone can find easily. |
@Lakston Could you please let me know that you implemented the feature of material2 or you followed @svstartuplab example to implement it. Thank you |
@svstartuplab it is pretty easy followed by that plnkr link above. 😃 |
All, please be aware of @jelbourn's note #5936 (comment) about that example plunker (#6095 (comment)) before you incorporate it. It works, but will probably be incompatible with future enhancements. |
@irowbin, From your example could you please let me know on row click how can you add a card with data. I am not able to add any card on row click. |
@vibingopal According to that plnkr link above, in your <md-row *cdkRowDef="let row; columns: displayedColumns; let index=index;"
(click)="expandRow(index)"
#cdkrow>
</md-row> The @ViewChildren('cdkrow', { read: ViewContainerRef }) containers: QueryList<ViewContainerRef>;
expandedRow: number;
source: DelegateDatasource; // datasource class
// method
expandRow(index: number) {
if (this.expandedRow != null) {
// clear old message
this.containers.toArray()[this.expandedRow].clear();
}
if (this.expandedRow === index) {
this.expandedRow = null;
} else {
const container = this.containers.toArray()[index];
const factory: ComponentFactory<ChildComponent> = this.resolver.resolveComponentFactory(ChildComponent);
const messageComponent = container.createComponent(factory);
messageComponent.instance.myData= this.source.data[index]; // my datasource array property
this.expandedRow = index;
}
} The @Component({
selector: 'data-details',
templateUrl: './child.component.html' // your html here
})
export class ChildComponent {
@Input() myData: IMyData;
} The entryComponents: [ChildComponent], // added to entry array
declarations: [ChildComponent] |
Thank you.. It can be implemented as well with ngx-datatable |
Cannot read property 'toArray' of undefined??? .html
.ts
expandRow(index: number) { |
Greetings, |
@shlomiassaf thanks for the updated demo! Any idea what would need to be changed to only allow one detail panel open at a time? ie: if one is open, change that opened state to closed, then open what was clicked. |
@EreckGordon That's quite a simple implementation, but a common one so I've added it to the example. Basically, the directive itself can be extended with some more things commonly required. The solution is to add an event to the directive, emitting when toggled. |
Thanks! |
@Triipaxx I don't understand what you refer to.... |
@shlomiassaf I think he's referring to the ripple that is not properly working on your example, the ripple is not contained in the row but ripples of the entire table, see this gif for an idea : The problem can be fixed by changing the I forked your stackblitz with a fix here Thanks for your example none the less, and for updating it 👍 |
Well no, that's not exactly what i was referring to. @Lakston Your problem can be solved by added the following to your CSS: But your gif shows my issue very well. If you look at the "Name" and "Weight" columns, you can see that the row content of these two columns shifts to the right while the ripple is animating, and jumps back to it's initial position afterwards. |
@Lakston I have to apologize. Your are right, what you have mentioned is an issue of the demo. This is probably related to the material version 6.0.0-rc1. |
Ok, i think i got a fix for my issue. I hope everyone understands what i was trying to say. English is not my native tongue. ;) |
Another simple implementation: @Component({
selector: 'my-master-detail-row',
template: `
<mat-expansion-panel>
<mat-expansion-panel-header class="mat-row">
<ng-container cdkCellOutlet></ng-container>
</mat-expansion-panel-header>
<div class="ief-detail-row">
<ng-content></ng-content>
</div>
</mat-expansion-panel>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
exportAs: 'matRow',
preserveWhitespaces: false,
})
export class MyMasterDetailRowComponent extends MatRow {
@HostBinding('class') clazz = my-master-detail-row';
} and use it like so <my-master-detail-row *matRowDef="let row; columns: displayedColumns;">
<div>this is a test</div>
</my-master-detail-row> |
@yogeshgadge I tried your solution but i have a problem with the header (not correctly aligned with the data). How did you handle the header? |
@DVLFocalor Add a column to the table in which you want to add this row. ( Use width 64px and no header text.) |
I implemented the expanded rows with |
@Triipaxx Since upgrading to Angular6/Material6 I've started experiencing the jank you described (and that the gif shows -- matRipple shifting the contents to the right), and cannot quite understand which piece of css you changed. For reference, this is my css that was working 100% fine in Angular5: .user-management-table-container {
display: flex;
flex-direction: column;
min-width: 30px;
}
.user-management-table-header {
min-height: 64px;
padding: 8px 24px 0;
}
.mat-form-field {
font-size: 14px;
width: 100%;
}
.mat-header-cell {
font-size: 20px;
}
.user-row {
position: relative;
}
.darken-on-hover:hover {
background-color: rgba(32, 32, 32, 0.2)
} what do you recommend changing? edit: here's the only instance in my html that uses matRipple. If I remove matRipple, problem goes away, but then I lose the nice ripple: <mat-row *matRowDef="let row; columns: displayedColumns;" matRipple class="user-row darken-on-hover" [cdkDetailRow]="row" [cdkDetailRowTpl]="expandedDetails" (toggleChange)="onToggleChange($event)"></mat-row> |
@EreckGordon |
@yogeshgadge 's extension does not work for me. All cell data gets put in the header when I replace a working edit: Figured it out! CdkTableModule must be imported for it to work (because CdkCellOutlet is used) |
Hi, @Lakston I tried your corrected version, but got at 'ng build' these warnings: WARNING in ./src/app/app.component.ngfactory.js WARNING in ./node_modules/@angular/material/menu/typings/index.ngfactory.js WARNING in ./node_modules/@angular/material/menu/typings/index.ngfactory.js WARNING in ./src/app/app.component.ngfactory.js WARNING in ./node_modules/@angular/material/menu/typings/index.ngfactory.js WARNING in ./src/app/app.component.ngfactory.js WARNING in ./src/app/app.component.ngfactory.js WARNING in ./src/app/app.module.ngfactory.js Anybody any ideas? |
I just tested my link and it works, maybe there was an error on Stackblitz's side when you tried ? I'll paste it again here just in case. |
Hi, yes you are right. It worked for. I had to rm node_modules and do a 'npm i' again. Everything works. Great work thank you. |
Hi, yes you are right. It worked for me. I had to rm node_modules and do a 'npm i' again. But now I get this error:
Everything works: My bad, I had to remove node_modules and reinstall the deps. |
@Lakston did You noticed that second and third column content is moving when You expand/collapse row? Do You know how this could be fixed? |
I did and no I haven't looked into it, this was just a proof of concept. |
the detail row directive example doesn't seem to work when used with material's native table usage.It adds the template as a cell as opposed to row. |
@james-schwartzkopf I used your solution in a previous project, but now I want to update that project to Angular 7 and I have difficulties with your library datasource-utils.ts in functions sortRows and paginateRows. I supposed is due to the new rxjs version. Are you still working in your solution? |
remove matRipple from mat-row. It will solve the issue. But it will remove animation as well. If you can live without animation, it will work. |
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. |
Bug, feature request, or proposal:
Hi Team,
Is it possible to extend the table row on click of the record.

For example, a table with more records exist and when the user clicked on particular row, the row should expand and show card with the row information in detail as shown below..
Material : 2.0.0-beta.8
Angular : 4.0.0
The text was updated successfully, but these errors were encountered: