How to add a double click listener to datatable fonts

What I want to do; when the user clicks on a row, he will select a row. When the user double-clicks the row, he will start editing the cell. The Primefaces storefront ( http://www.primefaces.org/showcase/ui/d ... nstant.jsf) says: "Instant line selection, dblclick and unselection selection is done using ajax behavior." but I could not find where they implemented the dblclick option. Is there a way to trigger a cell edit event with a double click event?

+4
source share
4 answers
<p:ajax event="rowDblselect"> 

From PrimeFaces User Guide

enter image description here

+13
source

In your face in your p: dataTable use:

 <p:dataTable id="yourTableId" var="yVar" value="#{yourBean.variableList}" selectionMode="single" selection="#{yourBean.variable}" rowKey="#{yVar.id}"> <p:ajax event="rowDblselect" listener="#{yourBean.onRowDblClckSelect}" update=":form:theComponentYouWantToUpdate" global="false" /> <!-- your columns here --> </p:dataTable> 

In your bean use:

 public void onRowDblClckSelect(final SelectEvent event) { YourObject obj = (YourObject) event.getObject(); // rest of your logic } 
+10
source

Try setting dblClickSelect="true" in the table.

From the documentation:

By default, row-based selection is triggered by a click event, activate dblClickSelect so that the double selection in the row makes a selection.

0
source

Here's a demonstration of using double-click Primefaces barcode sample

0
source

Source: https://habr.com/ru/post/1479535/


All Articles