Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to disable row-selection of datatable in primefaces

I am using Primefaces 4.0, I am having a datatable with multiple selection features.What Im willing to achieve is to select the rows only by the checkbox button, disabling capability of clicking a row. IN present scenario my checkbox is selected even if i click on any row, I want to disable row-selected.

<p:dataTable id="tradingTable" scrollable="true"
                resizableColumns="true" draggableColumns="true"  scrollWidth="1265"
                scrollHeight="650" var="pgers"
                selection="#{pager.selectedPageArray}"
                value="#{pager.pageDataModel}"
                sortMode="multiple"
                editable="true" editMode="cell" 
                rowSelectMode="add"     

                >  
                <p:column width="30" selectionMode="multiple"   >
                </p:column> 

I got some solution from this forum but unable to resolved it. Please suggest me what needed to be done.

like image 678
arvin_codeHunk Avatar asked Mar 21 '14 09:03

arvin_codeHunk


1 Answers

Although your question is about Primefaces 4.0, I thought it would be useful to highlight that this problem is now solved in newer versions. It may be useful to someone else.

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 162
YAM Avatar answered Oct 07 '22 22:10

YAM