jsfprimefacesprimefaces-datatable

How to trigger action on primefaces datatable row expansion only not rowToggle


I need the action to be triggered when expanding a row only, not when collapsing it, so basically rowToggle event doesn't work for me as it executes in both expanding and collapsing events

<p:ajax event="rowToggle" listener="#{queryStudiesBean.onRowToggle}" />

I need somthing like this, but with event="rowExpansion", but no rowExpansion event exists, so how can I do this?


Solution

  • You should use visibility property of the ToggleEvent:

    public void onRowToggle(org.primefaces.event.ToggleEvent event) {
      if (event.getVisibility() == Visibility.VISIBLE) {
        // Row was expanded
      }
    }