Primefaces dataTable: Is it possible to conditionally show a button? [duplicate]

心已入冬 提交于 2020-02-25 04:34:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!