admin管理员组文章数量:1125959
I have a p:dataTable
that is editable via RowEditor
. Now, I want to add a single selection per radio button (since rowSelection
by simply clicking on the row does not work with cellEditor).
The issue is that when I click on the radio button the selection doesnt change and the rowSelect event isnt triggered
Im using PrimeFaces 13.0.7 and heres the document:
Here is my DataTable
<p:dataTable id="exampleDatatable"
var="item"
value="#{bean.itemList}"
editable="true"
rowKey="#{item.id}"
selectionMode="single"
selection="#{bean.selectedItem}"
>
<p:ajax event="rowEdit" listener="#{bean.onRowEditItem}"/>
<p:ajax event="rowSelect" listener="#{bean.rowSelectItem"}/>
<p:column></p:column>
<p:column headerText="Id">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{item.id}"/>
</f:facet>
<f:facet name="input">
<h:outputText value="#{item.id}" style="width:100%"/>
</f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>
I have a p:dataTable
that is editable via RowEditor
. Now, I want to add a single selection per radio button (since rowSelection
by simply clicking on the row does not work with cellEditor).
The issue is that when I click on the radio button the selection doesnt change and the rowSelect event isnt triggered
Im using PrimeFaces 13.0.7 and heres the document: https://primefaces.github.io/primefaces/13_0_0/#/components/datatable
Here is my DataTable
<p:dataTable id="exampleDatatable"
var="item"
value="#{bean.itemList}"
editable="true"
rowKey="#{item.id}"
selectionMode="single"
selection="#{bean.selectedItem}"
>
<p:ajax event="rowEdit" listener="#{bean.onRowEditItem}"/>
<p:ajax event="rowSelect" listener="#{bean.rowSelectItem"}/>
<p:column></p:column>
<p:column headerText="Id">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{item.id}"/>
</f:facet>
<f:facet name="input">
<h:outputText value="#{item.id}" style="width:100%"/>
</f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>
Share
Improve this question
edited yesterday
seenukarthi
8,61410 gold badges50 silver badges73 bronze badges
asked 2 days ago
JoeJoe
313 bronze badges
1 Answer
Reset to default 1your code is wrong this is what you need to do...
selectionMode="single"
goes on the p:column
not on the DataTable.
See docs: https://primefaces.github.io/primefaces/13_0_0/#/components/datatable?id=single-selection-with-radiobutton
the value for selection="#{bean.selectedItem}"
must be a single item and it will detect it.
<p:dataTable var="car" value="#{carBean.cars}" selection="#{carBean.selectedCar}" rowKey="#{car.id}">
<p:column selectionMode="single"/>
...columns
</p:dataTable>
本文标签: primefacesDataTable selection with radioButtons not workingStack Overflow
版权声明:本文标题:primefaces - DataTable selection with radioButtons not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736631753a1945795.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论