DataTable: Enable row selection per button even if disabledSelection="true"
See original GitHub issueDescription
When we worked with PrimeFaces 8.0 it was possible to set disabledSelection=“true” on a p:dataTable so that the selection of a row was only possible by clicking on a designated button. With PrimeFaces 10.0 this was not possible anymore because if disabledSelection=“true” was set, no rows were highlighted anymore, despite the current selection. So we could use that feature only with a nasty workaround.
Describe the solution you would like
I think the use case for this is still valid, and maybe it can be re-enabled. I will attach a PR. Let me know what you think about it.
Additional context
For example, I use the dataTable as follow:
<p:dataTable var="car" value="#{dtBasicView.cars}" multiViewState="true" rowKey="#{car.number}" selection="#{dtBasicView.selectedCar}" selectionMode="single" disabledSelection="true" rows="60" paginator="true" lazy="false"
Important is disabledSelection=“true” so that the user can not select rows per click on a row or cell. It should only be possible with a click on a button that is included in every row.
That is made with a column that include a button like this:
<p:column headerText="Action" width="80"> <p:commandButton value="Select" update="@all" process="@this"> <f:setPropertyActionListener value="#{car}" target="#{dtBasicView.selectedCar}" /> </p:commandButton> </p:column>
That is like an example which is shown in the PrimeFaces documentation. So with PrimeFaces 10 I can select the row with that button, but the selected row is not highlighted as it should, which worked with PrimeFaces 8 (I also checked PF11 and the latest code base).
So my changes make that in that case the selected row is now highlighted.
I hope this will help to understand why I need that change. If you need more information, I will be happy to provide some.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:25 (25 by maintainers)
Do this instead:
And add this method in your bean:
I wonder if you really need to enable selection feature, maybe you should stick to your custom selection and forget what PF can do for you. It’s most probably simpler that way
Out of scope, but avoid
@all
unless it’s really really necessaryHi there, I just wanted to let you know, that I am on holiday for three weeks starting this weekend. There I have almost no internet access, so if you need something from me, I can only take care of it afterwards. So do not wonder if I do not reply to anything.