简体   繁体   English

Primefaces自动完成作为数据表过滤器

[英]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: 我应该使用哪个事件来触发过滤,在forceSelection旁边需要使用哪个选项来实际强制选择:

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”

            <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>

Propably onkeyup event sends string with incomplete value instead the converted plant. 可能是onkeyup事件发送了具有不完整值的字符串,而不是转换后的工厂。

Try to use p:ajax instead onXX events: 尝试使用p:ajax代替onXX事件:

                <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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM