简体   繁体   English

RowSelect事件p:dataTable

[英]RowSelect event p:dataTable

Need to capture the rowSelect event of a dataTable having checkbox based row selection. 需要捕获具有基于复选框的行选择的dataTable的rowSelect事件。 The code is as follows: 代码如下:

<p:ajax event="rowSelect" listener="#{articleBean.onRowSelect}"
                    oncomplete="articleBean.onSelection" />
<p:ajax event="rowUnselect" listener="#{articleBean.onRowUnselect}"
                    oncomplete="articleBean.onSelection" />
<p:column id="name" headerText="Select" selectionMode="multiple"
                    style="width:18px" />

I'm unable to understand the behavior. 我无法理解这种行为。 When I click checkbox for the first time, the method "onRowSelect" is getting called. 当我第一次单击复选框时,将调用方法“onRowSelect”。 When I unselect, "onRowUnselect" is not getting called. 当我取消选择时,“onRowUnselect”不会被调用。 And also, the "onRowSelect" method is called just once for the grid, as in, if I click any other checkbox, the event is not getting triggered. 而且,“onRowSelect”方法只为网格调用一次,如果我单击任何其他复选框,则事件不会被触发。 Am I missing out anything? 我错过了什么吗? Not able to understand this behavior. 无法理解这种行为。

As you are using dataTable with checkbox based row selection then you should replace: 当您使用带有基于复选框的行选择的dataTable时,您应该替换:

<p:ajax event="rowSelect"
<p:ajax event="rowUnselect"

With the following: 具有以下内容:

<p:ajax event="rowSelectCheckbox"
<p:ajax event="rowUnselectCheckbox"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM