Primefaces dataTable:是否可以有条件地显示按钮? [英] Primefaces dataTable: Is it possible to conditionally show a button?

查看:74
本文介绍了Primefaces dataTable:是否可以有条件地显示按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个dataTable,最后一列有一个按钮.根据第一列中的数据,我需要将按钮设为简单按钮或splitButton(提供更多操作).

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).

有没有办法实现这一目标?

我的数据表:

<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>

我并不总是需要其他动作".我依赖于当前行中的数据,例如myvar.id.有什么建议吗?

I don't always need the "Other action". I depends on the data in the current row, for example myvar.id. Any suggestions ?

推荐答案

您可以创建自己的条件并将其应用到Rendred中,例如在ManagedBean中创建一个Boolean并使用数据更改其值输入并像这样Rendred ="#{managedBeand.condition}"

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}"

这篇关于Primefaces dataTable:是否可以有条件地显示按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆