selectManyCheckbox formatting

UI Components for JSF
Post Reply
iastah
Posts: 1
Joined: 26 Sep 2011, 18:32

26 Sep 2011, 18:37

Is there any way to get the check boxes to wrap around. For example if my list is 23 items long, I'd like it to do 10 items on row one, 10 items on row two, and 3 items on row 3.

PrimeFaces 3.0.M3, JSF 2.1

ltune
Posts: 125
Joined: 20 Jul 2011, 20:25
Contact:

28 Sep 2011, 07:40

iastah wrote:Is there any way to get the check boxes to wrap around. For example if my list is 23 items long, I'd like it to do 10 items on row one, 10 items on row two, and 3 items on row 3.
Hello Iastah,

I would use the style option with valueExpression. Your item would look like this:

Code: Select all

<p:datatable value="myBackingBean.customCheckBoxList" var="myItem" />
[...]
<t:selectBooleanCheckbox value="#{myItem.selected}"  style="width:#{myItem.width}" />
[...]
</p:datatable>
Now, your ListItems must have a boolean (selected) attribute and a width attribute.

Of course, you can put valueExpressions even inside CSS files.

OK, after reading your post the third time, I am unsure know if you want wrap around checkbox text or the checkboxes ;) . In second case you would use a <ui:repeat /> with a inner container ( eg: <p:panel/>). As in my above example, you would add checkboxes values on a list as well. This woulld look like a table: a List<List<Boolean>. Each row (list item) would have a list of 10 checkboxes.

Your overhead is only in contructing this List of a 10item-bool List, once done <ui:repeat/> is fairly easy.

Finally, you will to get ten checkboxes on first line (first panel), 10 chechboxes on the second line (second panel) and so on.

EDIT: inside the container you would use a second ui:repeat to keep it simple. Thus, your code is short and last row can have 1,3, or 10 items.

EDIT: on second thought: just use a panelgrid with 10 items on a row ;)

Hope, I could help you.

Greets,

Adam
Busy applying primefaces patches to my local repo at /dev/null

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 55 guests