在另一个表的过滤器事件中重新渲染rich:extendedDataTable

时间:2013-04-08 17:07:41

标签: richfaces rerender

我的页面中有两个rich:extendedDataTables。一个是“主”,另一个是“奴隶”,因为从属数据依赖于主数据。

主人为每个列设置了filterBy。我希望能够在主表中的过滤器事件上rerender从表。

我最接近成功的是试图点击下面的“Return”按键,但效果不好:

<rich:hotKey selector="#masterTableEnclosingPanel" key="return" 
    handler="doSomethingA4jFunction()" preventDefault="true" type="onkeyup" /

我正在使用RichFaces 3.3.3。任何想法都非常受欢迎!


根据汗的要求,我添加了一些XHTML源代码。我正在使用RichFaces 3.3.3:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="........................">

<f:view>
    <head>
        <meta http-equiv="....................."/>
    </head>
    <body>
    <a4j:form id="my_form">

        <a4j:jsFunction name="handleMasterTableFiltering"
            oncomplete="myCustomFilterColumnsJSFunction()"
            reRender="slaveTablePanel"/>

        <rich:panel id="masterTablePanel">

<!-- MASTER TABLE -->
            <a4j:region id="masterTableEnclosingRegion">
                <rich:extendedDataTable rowKeyVar="rkv"
                    height="284px" width="100%" id="masterTable" rows="10"
                    columnClasses="col" value="#{BackingBean.masterTableModel}"
                    binding="#{BackingBean.masterTable}"
                    selection="#{BackingBean.selectionMasterTable}" var="master"
                    enableContextMenu="false" selectionMode="multi">

                    <a4j:support event="onselectionchange"
                        action="#{BackingBean.handleSelectionMasterTable}"
                        reRender="slaveTablePanel" />

                    <rich:column width="40px" sortBy="#{'ID'}" filterBy="#{'ID'}">
                        <f:facet name="header">
                            <h:outputText value="ID" />
                        </f:facet>
                        <h:outputText value="#{master.id}" id="master_id"/>
                    </rich:column>

                    <rich:column width="120px" sortBy="#{'NAME'}" filterBy="#{'NAME'}">
                        <f:facet name="header">
                            <h:outputText value="Name" />
                        </f:facet>
                        <h:outputText value="#{master.name}" id="master_name" />
                    </rich:column>

                    <rich:column width="140px" sortBy="#{'DESCRIPTION'}" filterBy="#{'DESCRIPTION'}">
                        <f:facet name="header">
                            <h:outputText value="Description" />
                        </f:facet>
                        <h:outputText value="#{master.description}" id="master_desc" />
                    </rich:column>

                </rich:extendedDataTable>
            </a4j:region>
<!-- END MASTER TABLE -->

        </rich:panel>

        <rich:spacer height="10px" />

        <rich:panel id="slaveTablePanel">

<!-- SLAVE TABLE -->
            <rich:panel id="slaveTableEnclosingPanel" 
                    style="height:325px; width:1210px; overflow:auto; border:0px; padding-top:0px;">
                <rich:extendedDataTable rowKeyVar="rkv"
                    height="282px" width="1758px" id="slaveTable" rows="10"
                    columnClasses="col" selectionMode="multi"
                    value="#{BackingBean.slaveTableModel}"
                    selection="#{BackingBean.selectionSlaveTable}"
                    binding="#{BackingBean.slaveTable }"    
                    var="slave" enableContextMenu="false">

                    <a4j:support event="onselectionchange" immediate="true"
                        action="#{BackingBean.handleSelectionSlaveTable}"/>

                    <rich:column width="40px" sortBy="#{'ID'}" filterBy="#{'ID'}">
                        <f:facet name="header">
                            <h:outputText value="ID" />
                        </f:facet>
                        <h:outputText value="#{slave.id}" id="slave_id"/>
                    </rich:column>

                    <rich:column width="120px" sortBy="#{'NAME'}" filterBy="#{'NAME'}">
                        <f:facet name="header">
                            <h:outputText value="Name" />
                        </f:facet>
                        <h:outputText value="#{slave.name}" id="slave_name" />
                    </rich:column>

                    <rich:column width="140px" sortBy="#{'DESCRIPTION'}" filterBy="#{'DESCRIPTION'}">
                        <f:facet name="header">
                            <h:outputText value="Description" />
                        </f:facet>
                        <h:outputText value="#{slave.description}" id="slave_desc" />
                    </rich:column>

                </rich:extendedDataTable>
            </rich:panel>
<!-- END SLAVE TABLE -->

        </rich:panel>

        <rich:hotKey selector="#masterTablePanel" key="return"
            handler="handleMasterTableFiltering()"
            preventDefault="true" type="onkeyup" />

    </a4j:form>

    </body>
</f:view>
</html>

2 个答案:

答案 0 :(得分:1)

解决方案是将slaveTablePanel放入reRender的{​​{1}}中:

masterTablePanel

问候:)

答案 1 :(得分:0)

尝试将以下内容添加到主表:

<a4j:support event="onkeyup"
             oncomplete="myCustomFilterColumnsJSFunction()"
             reRender="slaveTablePanel" />