1

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 ?

Tim
  • 3,910
  • 8
  • 45
  • 80

1 Answers1

0

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

Yagami Light
  • 1,756
  • 4
  • 19
  • 39
  • When i read your post i understand something different when you talk about showing or not a button you can work with `Rendred` or `Disabled` – Yagami Light Jul 27 '16 at 07:53
  • Thanks, I already checked the showcase and I am already using var, but I am not sure how to affect the structure of the table ? – Tim Jul 27 '16 at 07:54
  • i will provide an example it will be more clear ` ` – Yagami Light Jul 27 '16 at 07:55
  • I updated my question with an additional column – Tim Jul 27 '16 at 07:57
  • Hope that you see my example – Yagami Light Jul 27 '16 at 08:01
  • I think you misunderstood my question. I want the button to be different depending on the data in the table. Look at my code. For example: If myvar.id is even, I would like a single button, but if myvar.id is uneven, I would like the button to have another option. – Tim Jul 27 '16 at 08:06
  • ooooo i understand it is simple your have to use Rendred and add a condition look at this example ` ` – Yagami Light Jul 27 '16 at 08:09
  • 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}"` – Yagami Light Jul 27 '16 at 08:11
  • Your last comment solved my problem. Please update your answer and I'll accept it :) – Tim Jul 27 '16 at 08:18