Cássio
Cássio

Reputation: 329

Primefaces selectOneMenu doesn't roll the list to the typed character

I'm using primefaces 3.4, JBoss EAP 6.3, Java 1.7.0_79, JSF 2.0.

<p:selectOneMenu
    id="comboPais"
    value="#{requerenteEditarMB.bean.requerente.paisNascimento}"
    style="width:200px"
    var="e"
    converter="omnifaces.SelectItemsConverter"
    effect="fade">
    <f:selectItem
        itemValue=""
        itemLabel="#{messages['objeto.selecione.label']}" />
    <f:selectItems
        value="#{requerenteEditarMB.paisesLocalNascimento}"
        var="pais"
        itemValue="#{pais}"
        itemLabel="#{pais.nome}" />
    <p:column>
        <h:outputLabel
            value="#{e.nome}"
            styleClass="#{e.ativo ? '' : 'statusInativo'}" />
    </p:column>
    <a4j:ajax
        event="change"
        execute="prenome sobrenome dataNascimento comboPais "
        listener="#{requerenteEditarMB.contarPessoasSemelhantesRequerente}"
        render="qtdeSemelhantes">
    </a4j:ajax>
</p:selectOneMenu>

This list has over 200 records. When I type character "e", for example, I would expect the list rolls up to the first country whose name starts with "e", but instead the first country whose name starts with "e" is automatically selected and the list doesn't roll up. Current behavior Expected behavior

Upvotes: 0

Views: 900

Answers (1)

jwenting
jwenting

Reputation: 5663

ok, first things first: you should probably try to migrate to PF 5.3. It contains many fixes and new fuctionality.

Your selection won't scroll because you're using custom rendering for the columns, this blocks the scrolling.
You probably want to use a filter instead. See the PrimeFaces userguide.

From the documentation:

When filtering is enabled with setting filter on, an input field is rendered at overlay header and on keyup event filtering is executed on client side using filterMatchMode. Default modes of filterMatchMode are startsWith, contains, endsWith and custom. Custom mode requires a javascript function to do the filtering.

<p:selectOneMenu value="#{bean.selectedOptions}"
filterMatchMode="custom" filterFunction="customFilter">
<f:selectItems value="#{bean.options}" />
</p:selectOneMenu>

function customFilter(itemLabel, filterValue) {
//return true to accept and false to reject
}

Upvotes: 1

Related Questions