html - Primeng 表获取当前显示的行数
问题描述
我正在使用primeng表并为其启用了分页。我试图向用户显示当前显示的记录数和总记录数。类似于显示 200 个条目中的 1-20 个。但是,问题在于,如果记录不是 20 的倍数,则最后一页显示 194 个条目中的 180 到 200 个。我希望它是 194 个条目中的 180 到 194 个。请帮忙。提前致谢。
这是我的模板
<ng-template pTemplate="paginatorleft" let-state>
<span>Showing {{(state.page * state.rows) + 1}} to {{state.rows * (state.page + 1)}} of {{state.totalRecords}} entries
</ng-template>
解决方案
为什么不只是更新条件?
(state.totalRecords > (state.rows * (state.page + 1))) ? state.rows * (state.page + 1) : state.totalRecords
代替
state.rows * (state.page + 1)
推荐阅读
- ios - 我应该如何在 UITableView 下放置一个按钮并让它随着表格的增长而向下移动?
- .htaccess - Htaccess如何替换特殊字符序列
- javascript - 如何更改此代码以进行乘法运算?
- visual-studio-code - 如何修复 Visual Studio Code 终端中的“分段错误”错误?
- javascript - 带有变量的jquery选择器找不到元素
- powershell - 如何使用 PowerShell 基于 CSV 文件批量重命名其中的文件夹和文件?
- javascript - 如何从javascript的两个对象中创建一个对象?
- node.js - 删除具有相同特定名称值的最后一个 Sqlite 行
- c# - 在 C# 中将 StringBuilder 用于常量字符串?
- amazon-web-services - 将 API Gateway 与 CloudFront 一起使用,返回缺少的身份验证令牌