Richfaces列过滤器:如何在介绍键上触发事件 [英] Richfaces column Filter: How to fire an event on intro key

查看:74
本文介绍了Richfaces列过滤器:如何在介绍键上触发事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 rich:extendedDataTable ,我正在使用列过滤。我希望在用户输入简介键后触发过滤器,但在javascript中没有这样的事件。

I have a rich:extendedDataTable and I am using column filtering. I want the filter to be fired once the user enters the "intro" key, but in javascript there is no such event.

我想这样做,因为如果我使用诸如 onkeyup之类的事件我收到太多请求,因此我遇到了问题。我正在使用richfaces 3.3.0GA和facelets。

I want to do so because if I use events such as onkeyup I get too many requests and I have problems because of that. I'm using richfaces 3.3.0GA and facelets.

这是组件:

<ui:composition>
<a4j:form ajaxSingle="true" requestDelay="700">
    <rich:extendedDataTable id="tablePatients" value="#{user.patientsTab.patients}" var="patient" rows="20" 
        onRowMouseOver="this.style.backgroundColor='#F1F1F1'" onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
        <f:facet name="header">
            <h:outputText value="Patient List" />
        </f:facet>
        <rich:column label="#{msg.id}">
            <f:facet name="header">
                <h:outputText value="Id" />
            </f:facet>
            <h:outputText value="#{patient.id}" id="patientId" />
        </rich:column>
        <rich:column label="#{msg.name}"  sortable="true" filterBy="#{patient.profile.name}" filterEvent="onkeyup">
            <f:facet name="header">
                <h:outputText value="Name" />
            </f:facet>
            <h:outputText value="#{patient.profile.name}" id="name" style="#{patient.isUnrated? 'font-weight:bold':''}" />
        </rich:column >
        <rich:column label="#{msg.lastexamination}" sortable="true">
            <f:facet name="header">
                <h:outputText value="Last Examination" />
            </f:facet>
            <h:outputText value="#{patient.lastExaminationDate}" style="#{patient.isUnrated? 'font-weight:bold':''}" />
        </rich:column>
        <rich:column label="#{msg.action}">
            <f:facet name="header">
                <h:outputText value="#{msg.action}"></h:outputText></f:facet>
            <a4j:commandLink id="editlink" oncomplete="#{rich:component('patientPanel')}.show()" reRender="a4jPatientPanel">
                <h:graphicImage value="/images/icons/PNG-24/Add.png" style="border:0" />
                <f:setPropertyActionListener value="#{patient}" target="#{user.patientsTab.patientPanel.patient}" />
            </a4j:commandLink>
            <rich:toolTip for="editlink" value="Edit" />
        </rich:column>

        <f:facet name="footer">
            <rich:datascroller renderIfSinglePage="false" maxPages="5" />
        </f:facet>
    </rich:extendedDataTable>

    </a4j:form>

    <ui:include src="/pages/panels/patientPanel.xhtml" />
</ui:composition>


推荐答案

不幸的是,那里这不是定制此功能的简单方法。但是有一些选项可以让它更有用:

Unfortunately, there is no easy way to customize this functionality. There are options to make it more usable, though:


  • < a4j:queue requestDelay = 1000ignoreDupResponce =true/> - 将其放在< a4j:form> < a4j:region> ,您的 onkeyup 请求将被延迟并分组。请参阅 richfaces演示页

  • <a4j:queue requestDelay="1000" ignoreDupResponce="true" /> - place this in your <a4j:form> or <a4j:region> and your onkeyup requests will be delayed and grouped. See richfaces demo page:



  • 将ignoreDupResponces设置为true可减少输入内部键入时的DOM更新次数。 (初始状态更新次数等于请求次数)

  • 禁用队列会导致完全异步更新。请注意,更新可能不仅以直接顺序出现,因此您可能会收到错误的字符串。

  • 将请求延迟设置为更大的值会减少快速键入时的​​请求数。 (更多类似的请求在结果中合并)


  • 我目前正在使用以下替代方案:

  • I'm currently using the following alternative:

    <rich:dataTable (..some attributes..)
        onkeypress="if (event.keyCode == 13) {document.getElementById('formId:tableId:j_id70fsp').blur(); return false;} else {return true;}"
        ><!-- disabling submit-on-enter -->
        <rich:column label="#{msg.name}" sortable="true" 
           filterBy="#{patient.profile.name}" filterEvent="onblur">
    </rich:dataTable>
    

    你必须看到生成的id j_id70fsp 。但是不能保证它会永远保持下去。

    Where you have to see the generated id for j_id70fsp. It is not guaranteed that it will remain such forever, though.

    结果是按下回车键过滤了列,这是相当可用的。

    And the result is that the column is filtered on pressing the enter key, which is fairly usable.

    这篇关于Richfaces列过滤器:如何在介绍键上触发事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆