问题
I have a dataTable and there is a button in the last column. Depending on the data in the first column, I need the button to be either a simple button or a splitButton (offering more actions).
Is there a way to achieve this ?
My dataTable:
<p:column headerText="id">
<h:outputText value="#{myvar.id}" />
</p:column>
<p:column>
<p:splitButton value="View"
actionListener="#{bean.method}" />
<p:menuitem value="Other action"
actionListener="#{bean.method2" />
</p:splitButton>
</p:column>
I don't always need the "Other action". I depends on the data in the current row, for example myvar.id. Any suggestions ?
回答1:
You can create your own condition and apply it in the Rendred
for example create a Boolean
in your ManagedBean
and change it value with the data type and make it like that Rendred ="#{managedBeand.condition}"
来源:https://stackoverflow.com/questions/38606308/primefaces-datatable-is-it-possible-to-conditionally-show-a-button