单击Primefaces数据表中的其他行时不要取消选择行 [英] Do not unselect rows when clicking on another rows in Primefaces datatable

查看:50
本文介绍了单击Primefaces数据表中的其他行时不要取消选择行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Primefaces 3.5数据表.该表启用了多选模式.基本上,该表格与[此展示柜] [1]中的最后一张相同.所以表是这样定义的

I'm working with Primefaces 3.5 Data Table. The table is with multiselection mode enabled. Basically, the table is the same as the last one from [this showcase][1]. So the table is defined like this

<p:dataTable id="myTable" var="item" value="#{myController.items}" selection="#{myController.selectedItems}" rowKey="#{item.id}">
        <p:column selectionMode="multiple"/>
        <p:column headerText="Id"> 
...

因此,当用户通过单击复选框选择某些行,然后不小心单击了一行时,所有选定的行都将变为未选择状态,但最后单击的行除外.

So when the user selects some rows by clicking on checkboxes and then accidentally clicks on one row, all selected rows become unselected except the one on which user clicked at last.

问题是:即使用户单击复选框之外的行,是否有任何变通办法来维持选定的行?

The question is: Is there any workaround to maintain rows selected even if user will click on the row out of checkbox?

我的一些观察结果

  • 如果用户将按 Ctrl 并单击该行,则所有其他行将保持选中状态.这种行为正是我想要的,但是没有按 Ctrl .
  • 我查看了 primefaces.js 的源代码,发现此函数 clearSelection:function(){} 取消了其他行的选择.当用户单击行时,最好不执行它.
  • If the user will press Ctrl and click on the row all other rows will maintain selected. This behavior is exactly what I want, but without pressing Ctrl.
  • I've looked at primefaces.js source and found that other rows are deselected by this function clearSelection:function(){}. It would be fine to do not execute it when user will click on row.

推荐答案

如果阅读了最新的文档,则可以看到它在较新的版本中受支持.因此,要针对3.5进行修复,请查看较新版本的源代码,以了解如何修复"此问题并创建js补丁…当然,您也可以尝试使用较新的PF版本.进行后者时有很多优势.

If you read the more recent documentation, you can see it is supported in newer releases. So to fix this for 3.5, look at the source of the newer releases on how they 'fixed' this and create a js patch… You can ofcourse also try to use a newer PF version. Lots of advantages when doing the latter.

在此处发布(或尝试创建)补丁(或尝试创建一个补丁)的原因是,在此处发布和发布超出SO范围的imo是很复杂的事情

The reason for not posting (or even trying to create) a patch here (or trying to create one) is that it is waaaaay to complex to post here and imo beyond the scope of SO

这篇关于单击Primefaces数据表中的其他行时不要取消选择行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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