[英]Expandable nested Angular material data tables with pagination Not working as expected?
I have a requirement that nested table with tabs, I am using angular material.我有一个带有标签的嵌套表的要求,我使用的是 angular 材料。
Required pagination for Branch Data(server Side Pagigantion) and inner tables within a two tabs(client side pagigantion) as well分支数据(服务器端分页)和两个选项卡中的内表(客户端分页)也需要分页
it's not working as expected, Pagigantion is applying one for 0 index, from second recored I fi click second page paging it's updating third table, third-> 4 th updating它没有按预期工作,Pagigantion 正在为 0 索引应用一个,从第二个记录我点击第二个页面分页它正在更新第三个表,第三个 - > 第 4 个更新
I taken like thease我喜欢thease
//branch //分支
branchSource: MatTableDataSource;分支源:MatTableDataSource;
@ViewChild('branchSort', { static: true }) sort: MatSort; @ViewChild('branchSort', { static: true }) 排序:MatSort;
@ViewChild(MatPaginator, { static: true }) branchPaginator: MatPaginator; @ViewChild(MatPaginator, { static: true }) branchPaginator: MatPaginator;
//tab1 //tab1
@ViewChildren('innerTables') innerTables: QueryList<MatTable>; @ViewChildren('innerTables') innerTables: QueryList<MatTable>;
@ViewChildren(MatPaginator) paginator: QueryList; @ViewChildren(MatPaginator) 分页器:QueryList;
@ViewChildren('innerSort') innerSort: QueryList; @ViewChildren('innerSort') 内部排序:查询列表;
//tab2 //tab2
@ViewChildren('innerTables1') innerTables1: QueryList<MatTable>; @ViewChildren('innerTables1') innerTables1: QueryList<MatTable>;
@ViewChildren('innerSort1') innerSort1: QueryList; @ViewChildren('innerSort1') 内部排序1:查询列表;
@ViewChildren(MatPaginator) paginator1: QueryList; @ViewChildren(MatPaginator) paginator1: QueryList;
For Reference Please check: < https://stackblitz.com/edit/angular-nested-mat-table-2ave8p?file=app%2Ftable-expandable-rows-example.ts>参考请查看:< https://stackblitz.com/edit/angular-nested-mat-table-2ave8p?file=app%2Ftable-expandable-rows-example.ts>
Suggest me good approach to fullfill the requiremnet.建议我完成requiremnet的好方法。 Thanks in advance提前致谢
I solved my problem我解决了我的问题
The problem is mat viewchild reference问题是 mat viewchild 参考
I modified my code like this我像这样修改了我的代码
@ViewChild('branchSort', { static: true }) sort: MatSort;
@ViewChildren('innerSort') innerSort: QueryList<MatSort>;
@ViewChildren('innerSort1') innerSort1: QueryList<MatSort>;
@ViewChildren('innerTables') innerTables: QueryList<MatTable<any>>;
@ViewChildren('innerTables1') innerTables1: QueryList<MatTable<any>>;
@ViewChildren('paginator') paginator: QueryList<MatPaginator>;
@ViewChildren('paginator1') paginator1: QueryList<MatPaginator>;
@ViewChild(MatPaginator, { static: true }) batchPaginator: MatPaginator;
https://stackblitz.com/edit/angular-nested-mat-table-dmzvun?file=app%2Ftable-expandable-rows-example.ts https://stackblitz.com/edit/angular-nested-mat-table-dmzvun?file=app%2Ftable-expandable-rows-example.ts
Super!极好的!
Just a fix in your stackblitz line 344 this.branchSource.paginator = this.batchPaginator;
只需在您的 stackblitz 行 344 this.branchSource.paginator = this.batchPaginator;
Thanks for sharing感谢分享
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.