0 Replies Latest reply on May 7, 2012 4:50 AM by Fuat Akal

    How to rerender a particular column of a datatable?

    Fuat Akal Newbie

      Hello all,

       

      I have a table consisting of two columns, columnA and columnB (See the source below). What i would like to do is to re-render all cells in columnB, as soon as any value in that column is changed.

       

      I tried many things but i did not make it work. So, i had to rerender the entire table.

       

      reRender="my-form:myTable"

       

      Funny thing is, in the header sections of the table

       

      reRender="myTable:columnB"

       

      works exactly the way i want (I did not understand how it really works though).

       

      Could somebody tell me how i can re-render a particular column in the datatable?

       

      I would appreciate any help.

       

      Kind Regards

      Fuat

       

      >>>>

       

      <ui:composition

        xmlns="http://www.w3.org/1999/xhtml"

        xmlns:s="http://jboss.com/products/seam/taglib"

        xmlns:ui="http://java.sun.com/jsf/facelets"

        xmlns:f="http://java.sun.com/jsf/core"

        xmlns:h="http://java.sun.com/jsf/html"

        xmlns:rich="http://richfaces.org/rich"

        xmlns:a4j="http://richfaces.org/a4j"

        template="/layout/template.xhtml">

       

        <ui:define name="body">

       

          <rich:panel>

       

            <a4j:form id="my-form">

              <s:validateAll>

                <rich:dataTable

                  id="myTable"

                  value="#{myManager.items}"

                  var="item">

                  <rich:column id="columnA">

                    <f:facet name="header">

                      <s:div>

                        <h:inputText value="#{myManager.allRowsColumnA}">

                          <a4j:support

                            event="onchange"

                            action="#{myManager.changeColumnAForAllRows}"

                            reRender="myTable:columnA"

                            ajaxSingle="true" />

                        </h:inputText>

                        <br />

                        <h:outputText value="Column A" />

                      </s:div>

                    </f:facet>

                    <h:inputText

                      id="inputColumnA"

                      value="#{item.columnA}"

                      required="true">

                    </h:inputText>

                  </rich:column>

       

                  <rich:column id="columnB">

                    <f:facet name="header">

                      <s:div>

                        <h:inputText value="#{myManager.allRowsColumnB}">

                          <a4j:support

                            event="onchange"

                            action="#{myManager.changeColumnBForAllRows}"

                            reRender="myTable:columnB"

                            ajaxSingle="true" />

                        </h:inputText>

                        <br />

                        <h:outputText value="Column B" />

                      </s:div>

                    </f:facet>

                    <h:inputText

                      id="inputColumnB"

                      value="#{item.columnB}"

                      valueChangeListener="#{myManager.columnBChanged}"

                      required="false">

                      <a4j:support

                        event="onchange"

                        reRender="my-form:myTable"

                        ajaxSingle="false" />

                    </h:inputText>

                  </rich:column>

       

                </rich:dataTable>

       

              </s:validateAll>

            </a4j:form>

          </rich:panel>

        </ui:define>

      </ui:composition>