Note that there are some explanatory texts on larger screens.

plurals
  1. POFilter not working in primefaces dataTable with drag and drop
    primarykey
    data
    text
    <p>drag, drop and sorting working fine for me but filtering not working properly(filter working only once). If any one gets solutions means kindly help me.</p> <p><strong>index.xhtml</strong></p> <pre><code> &lt;?xml version='1.0' encoding='UTF-8' ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui"&gt; &lt;h:head&gt; &lt;script type="text/javascript"&gt; function handleDrop(event, ui) { var droppedCar = ui.draggable; droppedCar.fadeOut('fast'); } &lt;/script&gt; &lt;/h:head&gt; &lt;h:body&gt; &lt;h:form id="carForm"&gt; &lt;p:dataTable id="availableCars" var="car" value="#{Report.field1}"&gt; &lt;p:column sortBy="#{car.values}" filterBy="#{car.values}" headerText="Properties"&gt; &lt;h:outputText id="dragIcon" value="#{car.values}" /&gt; &lt;p:draggable for="dragIcon" revert="true" /&gt; &lt;/p:column&gt; &lt;/p:dataTable&gt; &lt;p:fieldset id="selectedCars" style="margin-top:20px"&gt; &lt;p:outputPanel id="dropArea"&gt; &lt;h:outputText value="!!!Drop here!!!" rendered="#{empty Report.field2}" style="font-size:24px;" /&gt; &lt;p:dataTable var="car" value="#{Report.field2}" rendered="#{not empty Report.field2}"&gt; &lt;p:column headerText="Color"&gt; &lt;h:outputText value="#{car.values}" /&gt; &lt;/p:column&gt; &lt;/p:dataTable&gt; &lt;/p:outputPanel&gt; &lt;/p:fieldset&gt; &lt;p:droppable for="selectedCars" tolerance="touch" activeStyleClass="ui-state-highlight" datasource="availableCars" onDrop="handleDrop"&gt; &lt;p:ajax listener="#{Report.onCarDrop}" update="dropArea availableCars" /&gt; &lt;/p:droppable&gt; &lt;/h:form&gt; &lt;/h:body&gt; &lt;/html&gt; </code></pre> <p>and backbeans are</p> <p><strong>tempReport.java</strong></p> <pre><code> public class tempReport { public String values; public tempReport(String values) { this.values=values; } public String getValues() { return values; } public void setValues(String values) { this.values=values; } } </code></pre> <p><strong>ReportGenerator.java</strong></p> <pre><code> import java.io.Serializable; import java.util.ArrayList; import java.util.List; import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; import org.primefaces.event.DragDropEvent; @ManagedBean(name="Report") @RequestScoped public class ReportGenerator implements Serializable { static List&lt;tempReport&gt; field1=new ArrayList&lt;tempReport&gt;(),field2=new ArrayList&lt;tempReport&gt;(); static int i=1; public ReportGenerator() { if(i==1) { field1=new ArrayList&lt;tempReport&gt;(); field2=new ArrayList&lt;tempReport&gt;(); field1.add(new tempReport("one")); field1.add(new tempReport("two")); field1.add(new tempReport("three")); field1.add(new tempReport("four")); field1.add(new tempReport("five")); field1.add(new tempReport("six")); i++; } } public List&lt;tempReport&gt; getField1() { return field1; } public void setField1(List&lt;tempReport&gt; field1) { this.field1=field1; } public List&lt;tempReport&gt; getField2() { return field2; } public void setField2(List&lt;tempReport&gt; field2) { this.field2=field2; } public void onCarDrop(DragDropEvent ddEvent) { tempReport car = ((tempReport) ddEvent.getData()); int x=0; for(tempReport item: field2) { if(item==car) x=1; } if(x==0) field2.add(car); } } </code></pre> <p>Thank you</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload