仅带有复选框选择的Primefaces数据表 [英] Primefaces datatable with checkbox selection ONLY

查看:105
本文介绍了仅带有复选框选择的Primefaces数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我将数据表与<p:column selectionMode="multiple" />一起使用 以便可以使用复选框对条目进行多次选择.

In my project, I use datatable with <p:column selectionMode="multiple" /> so that the entries can be multiple selected using the checkboxes.

但是,当用户单击一行时,所有先前的选择都未被选择,而仅选择了该行. 此行为是意外的和令人讨厌的. 我想在单击行时禁用rowSelect和rowUnselect的行为,但似乎除了破解datatable.js的源代码外,我无能为力.

However, when the user click on a row, all previous selection is unselected and only that row is selected. This behaviour is unexpected and annoying. I would like to disable the behaviour of rowSelect and rowUnselect on row clicking, but seems I had no way to do but hacking the source of datatable.js.

有人以前实现过吗?感谢您的回答.

Does anyone implement this before? Thanks for answering.

使用:

primefaces 3.5

primefaces 3.5

mojarra 2.1.6

mojarra 2.1.6

玻璃鱼3.1.2.2

glassfish 3.1.2.2

推荐答案

根据此功能请求,Primefaces版本 5.0.3 &中现在支持此功能.只需将rowSelectMode ="checkbox"添加到数据表即可 5.1 .

According to this feature request, this feature is now supported in Primefaces versions 5.0.3 & 5.1 by simply adding rowSelectMode="checkbox" to the datatable.

文档参考(PF 5.1):

Documentation reference (PF 5.1):

使用rowSelectMode选项来自定义行的默认行为 单击启用多项选择的数据表.默认值为 新"清除先前的选择,添加"模式保留先前的选择 选择与在meta键打开时用鼠标单击选择行相同 和复选框"模式只允许选择带有复选框的行.

Use rowSelectMode option to customize the default behavior on row click of a multiple selection enabled datatable. Default value is "new" that clears previous selections, "add" mode keeps previous selections same as selecting a row with mouse click when metakey is on and "checkbox" mode allows row selection with checkboxes only.

这篇关于仅带有复选框选择的Primefaces数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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