Skip to content

How to disable a Main Edit button only when No Rows Selected? #211

Closed Answered by FlipWarthog
NCIDevRonR asked this question in PrimeFaces
Discussion options

You must be logged in to vote

It looks like the selection ajax events of the table itself aren't updating all the buttons needed, which would lead to the behavior you're describing. An easy solution would be to leverage the Observer in PrimeFaces: https://www.primefaces.org/showcase/ui/ajax/observer.xhtml?jfwid=5ba9f

Just need to switch the ajax events in the table to:

<p:ajax event="rowSelectCheckbox" update="@obs(selection-changed)" />

Then, any component that needs to update based on selection changing would just need <p:autoUpdate on="selection-changed"/>:

</p:commandButton>
    <p:commandButton id="btnEditCityInfo" value="Edit"
                 icon="pi pi-pencil" actionListener="#{cityInfoController.openEdit}"

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@NCIDevRonR
Comment options

Answer selected by NCIDevRonR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
2 participants