4 Replies Latest reply on Oct 8, 2015 11:31 AM by Michal Petrov

    extendedDataTable selection x 2nd click

    Edilmar Alves Expert

      Hi,

       

      I have this extendedDataTable with selection control to allow the user to click in a row and to open a popupPanel to update the values of the fields/columns.

      The problem is: when I have just one row in the table and I click to open the panel, when I come back to the main form with the table, the row is already selected,

      and I don't get to click again to reopen the panel. If I have two or more rows, I get to solve this problem clicking other row, opening/closing the panel, and clicking

      again the correct row I would like to change values. I use RF 4.5.6.

       

      <rich:extendedDataTable id="table"

                              var="item" rowKeyVar="rowListTable"

                              selection="#{ordemServicoComp.selectionTableItemOS}" selectionMode="single"

                              value="#{ordemServicoComp.listTableItemOS}">

        <a4j:ajax event="selectionchange"

                  execute="@this" render="cadastrarItemOSGrid"

                  listener="#{ordemServicoComp.abrirAlterarItemOS}"

                  oncomplete="#{rich:component('cadastrarItemOSPanel')}.show();"/>

      ...

        • 1. Re: extendedDataTable selection x 2nd click
          Michal Petrov Master

          Well, onselectionchange fires only if the selection changes. I'm assuming you rerender the table after you update the data, clear the selection when you do that.

          • 2. Re: extendedDataTable selection x 2nd click
            Edilmar Alves Expert

            I did this to clear selection:

             

            1) Method to update the row in the JSF controller called by "Gravar" (Save) button in the popupPanel:

              private Collection<Object> selectionTableItemOS;

              ...

              public String gravarItemOS() {

                ... logic to update data in the database ...

                selectionTableItemOS.clear();

                selectionTableItemOS = null;

                return null;

              }

             

             

            2) Code to clear the selection in the xhtml popupPanel button:

                  <a4j:commandButton value="Gravar" action="#{ordemServicoComp.gravarItemOS}"
                                     render="table" execute="cadastrarItemOSPanel"
                                     oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('cadastrarItemOSPanel')}.hide();#{rich:component('table')}.setActiveRow(null);}" />

             

            Then, the table becomes without row selected after the user clicks "Gravar" button, saves the data and returns to the main page.

            The problem is that if I clicks again in the same row, no selection is made and the popupPanel is not opened. Just like before.

            • 3. Re: extendedDataTable selection x 2nd click
              Edilmar Alves Expert

              I got using this:

               

              #{rich:component('table')}.deselectRow(#{rich:component('table')}.activeIndex);

              • 4. Re: extendedDataTable selection x 2nd click
                Michal Petrov Master

                When you rerender the table and the row is unselected it should select the row again, if that doesn't happen the error is somewhere in the JavaScript.

                 

                This works fine for me:

                <rich:extendedDataTable value="#{[1]}" selection="#{bean.selection}" var="i" id="table">
                    <rich:column>#{i}</rich:column>
                    <a4j:ajax event="selectionchange" oncomplete="#{rich:component('panel')}.show()" />
                </rich:extendedDataTable>
                <rich:popupPanel id="panel">
                    <a4j:commandButton action="#{bean.clearSelection()}" value="Clear and Close" render="table"
                        oncomplete="#{rich:component('panel')}.hide();" />
                </rich:popupPanel>
                

                (bean.selection is an Object, clearSelection() sets it to null)