angular - Primeng 复选框上的多行选择和单击行时的单选
问题描述
您好,我需要通过单击复选框进行多项选择,并在单击行后进行单选。你知道我怎样才能在同一张桌子上加入这个吗?
https://www.primefaces.org/primeng/showcase/#/table/selection
解决方案
您可以使用onRowSelect
从选择中删除所有其他内容,但单击的项目除外。
您的 p 表定义将如下所示:
<p-table selectionMode="multiple" [(selection)]="selectedItems" (onRowSelect)="onRowSelect($event) ...> ... </p-table>
和你的功能
onRowSelect(event) {
this.selectedItems = [event.data];
}
所以复选框使用默认的primeng行为,而行单击取消选择其他所有内容。
推荐阅读
- javascript - 如何为迷你图 highcharts 表制作边框?
- regex - pl/sql 字符串转换 - 正则表达式
- php - 禁用从当前应用程序 php 登录
- python - Flask flash 消息在使用 alert 时倾向于显示 ' 代码
- java - Eclipse - 忽略 maven-war-plugin 运行 maven 包
- javascript - 从 TypeScript 中的 URL 下载文档
- python - 如何将文本拆分为列表?
- swift - Podspec 依赖特定的 swift 版本
- angular - 使用 angular 2 创建 PDF 的最佳方法
- android - 运行一个安卓项目