Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep primefaces rowexpansion open?

Tags:

jsf

primefaces

I have a nested datatable with row expension so far so god, but I want to keep all rows expanded (open) how to achieve this on primefaces?

thanks in advance.

Sorry, I didn't tell what version of primefaces am I using, version 3.5.

like image 530
danillosl Avatar asked Jan 21 '26 03:01

danillosl


1 Answers

According to the Primefaces 4.0 documentation:

p:rowToggler component places an expand/collapse icon, clicking on a collapsed row loads expanded content with ajax. If you need to display a row as expanded by default, use expandedRow attribute which is evaluated before rendering of each row so value expressions are supported.

To keep all rows open, use it in your datatable like this:

<p:dataTable value="#{bean.list}" expandedRow="#{true}">

To keep the rows open that were open before an update, you need to:

  • Keep track (server side might be best) of which rows are opened and closed manually (do this via ajax)
  • On (re)loading the p:dataTable you should in the expandedRow attribute put an EL that evaluates the current row it is processing (use the var attribute or the index on the datatable or the rowkey) that returns true for each row that was expanded before.

Something like this (not fully tested)

<p:dataTable value="#{bean.list}" var="myRow" expandedRow="#{bean.isExpanded(myRow)}">

Here is the feature request at google code, which was targeted for 3.5.12 and 4.0.

like image 56
Xtreme Biker Avatar answered Jan 24 '26 00:01

Xtreme Biker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!