Damian
Damian

Reputation: 3050

Primefaces autocomplete as a datatable filter

I can't make it work. Component is sending only part of what is actually in the input. What event should I use to trigger filtering, what option beside forceSelection is needed to actually force selection:

This what is send from a request

InboundShipmentListForm:datalist:j_idt98_input:Select One...
InboundShipmentListForm:datalist:j_idt104_focus:
InboundShipmentListForm:datalist:j_idt104_input:Select One...
InboundShipmentListForm:datalist:j_idt110_input:p
InboundShipmentListForm:datalist:j_idt110_hinput:p

A unexpected error occured! Message: For input string: "p"

            <p:column filterBy="#{item.supplierPlant}"
                sortBy="#{item.supplierPlant}"
                headerText="#{bundle.ListInboundShipmentTitle_supplierPlant}"
                style="width:auto; text-align:center">

                <!-- autocomplete -->
                <f:facet name="header">
                    <f:facet name="filter">

                        <p:autoComplete forceSelection="true" itemValue="#{plant}" converterMessage="Select a value"
                            onchange="PF('datalist').filter()" dropdown="true"
                            onkeyup="PF('datalist').filter()"
                            completeMethod="#{inboundShipmentController.completeSuppliers}"
                            var="plant" itemLabel="#{plant.plantName}"
                            converter="plantConverter" a:placeholder="Start typing ..." />
                    </f:facet>
                </f:facet>
                <h:outputText value="#{item.supplierPlant.plantName}" />
            </p:column>

Upvotes: 0

Views: 2479

Answers (1)

Pavel V
Pavel V

Reputation: 186

Propably onkeyup event sends string with incomplete value instead the converted plant.

Try to use p:ajax instead onXX events:

                <f:facet name="filter">
                    <p:autoComplete forceSelection="true" itemValue="#{plant}" converterMessage="Select a value"
                                    completeMethod="#{inboundShipmentController.completeSuppliers}"
                                    var="plant" itemLabel="#{plant.plantName}"
                                    converter="plantConverter" a:placeholder="Start typing ...">
                        <p:ajax event="itemSelect" onstart="PF('datalist').filter()" />
                    </p:autocomplete>
                </f:facet>

Upvotes: 4

Related Questions