Angular Material Table 设置默认行数 [英] Angular Material Table set default number of rows

查看:26
本文介绍了Angular Material Table 设置默认行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在页面加载时在表上设置一些还没有数据的行.如果我单击一个按钮来显示数据列表,它将填充我设置的 n 个数字的行.

I want to set a number of rows on the table on page load having no data yet. If I click a button for me to display the list of data it will then populate the rows for n number I set.

我已经尝试在垫子上添加默认长度.

I already tried adding a default length on the matrow.

假设 ngOnInit() 将显示 8 行,当我单击一个按钮显示数据时,它会填满我设置的 8 行,并且仍然使用 mat-paginator 进行分页.

Let say ngOnInit() it will display 8 rows and when I click a button to display the data, it would fill up the 8 rows I set and there's still a pagination using mat-paginator.

这可能吗?

推荐答案

根据初始行数使用空数据填充,然后在点击按钮时加载真实数据.

Populate using empty data according to the number of initial rows, then load real data when the button is clicked.

Stackblitz:https://stackblitz.com/edit/angular-f3g5vu?file=app%2Ftable-pagination-example.ts

Stackblitz: https://stackblitz.com/edit/angular-f3g5vu?file=app%2Ftable-pagination-example.ts

这篇关于Angular Material Table 设置默认行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆