Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Primefaces datatable with checkbox selection ONLY

Tags:

jsf

primefaces

In my project, I use datatable with <p:column selectionMode="multiple" /> so that the entries can be multiple selected using the checkboxes.

However, when the user click on a row, all previous selection is unselected and only that row is selected. This behaviour is unexpected and annoying. I would like to disable the behaviour of rowSelect and rowUnselect on row clicking, but seems I had no way to do but hacking the source of datatable.js.

Does anyone implement this before? Thanks for answering.

Using:

primefaces 3.5

mojarra 2.1.6

glassfish 3.1.2.2

like image 205
Wilkin Ho Avatar asked Feb 28 '13 06:02

Wilkin Ho


1 Answers

According to this feature request, this feature is now supported in Primefaces versions 5.0.3 & 5.1 by simply adding rowSelectMode="checkbox" to the datatable.

Documentation reference (PF 5.1):

Use rowSelectMode option to customize the default behavior on row click of a multiple selection enabled datatable. Default value is "new" that clears previous selections, "add" mode keeps previous selections same as selecting a row with mouse click when metakey is on and "checkbox" mode allows row selection with checkboxes only.

like image 64
YAM Avatar answered Nov 01 '22 19:11

YAM