8 Replies Latest reply on May 21, 2011 9:12 AM by ilya_shaikovsky

    Dynamic columns visibility

    vali_iva

      Hi, I'm trying to toogle the visibility of column from an extendedDataTable with a checkbox.

      When I check the box, the table gets reRendered, the value in bean is changed but the column does't dis/appear.

       

      I can't figgured it aout what is wrong.

       

      Here is the code snippet:

       

       

      <rich:extendedDataTable id="indexes" value="#{asetsScreener.indexes}" 
                     var="index"  height="400px" width="900px"
                     title="Indexes" selectionMode="none">
           <rich:column width="40px">
           <a4j:facet name="header"> Index </a4j:facet>
           <h:outputText value="#{index.indicator}"/>
           </rich:column>
           <rich:column width="40px">
           <a4j:facet name="header"> Show </a4j:facet>
           <h:selectBooleanCheckbox value="#{index.shown}">
                     <a4j:support event="onclick" reRender="compsTable, testtest"/>
           </h:selectBooleanCheckbox>
           </rich:column>
           <rich:column width="250px" style="text-align:right;">
                <a4j:facet name="header"> Min Value </a4j:facet>
                <rich:inputNumberSlider id="minRangeSlider"
                                    value="#{index.minRange}"
                                    minValue="#{index.min}"
                                    maxValue="#{index.max}"
                          onmouseup="slide(this)" oninputkeyup="slide(this)"
                                    showArrows="false"
                          inputPosition="right">
                     <a4j:support event="onchange" reRender="minRangeSlider"/>
              </rich:inputNumberSlider>
           </rich:column>
      </rich:extendedDataTable>
      
      
      

       

      Here I have a list of checkboxes and sliders. And for every checkbox that is checked, a column should be shown in the next table:

       

       

      <a4j:outputPanel id="companies" ajaxRendered="true">
           <rich:extendedDataTable value="#{asetsScreener.comps}" id="compsTable" 
                                   var="comp" selectionMode="none"  height="210px" >
                 <rich:column visible="true">
                      <f:facet name="header">
                           <h:outputText value="Company"/>
                      </f:facet>
                      <h:outputText value="#{comp['CompanyName']}"/>
                 </rich:column>
                 <rich:columns value="#{asetsScreener.indexes}" var="column" 
                                 visible="#{column.shown}">
                      <f:facet name="header">
                           <h:outputText value="#{column.indicator}"/>
                      </f:facet>
                      <h:outputText value="#{comp[column.indicator]}"/>
                 </rich:columns>
           </rich:extendedDataTable>
           <h:outputText value="#{asetsScreener.indexes[1].shown}" id="testtest"/>
      </a4j:outputPanel>
      

       

       

      If I check some boxes and hit refresh, the right columns are diplayed. But I don't want it on page refresh, I want it on checkbox event.

      If I change the value of the inputNumberSlider, then all the columns are made visible although no checkbox is checked.

       

      It has a wired behaviour.

       

      I would be gratefull if you guys could help me with this.

       

      Thanks.

       

      Vali

       

      And almoust forget. I use RF 3.3.3 Final with facelets. on tomcat 6

        • 1. Dynamic columns visibility
          mp911de

          Hi Valentin,

          this is because you take the visibility from your Row-Variable. As there can be multiple rows this is a bad Idea. Move your visibility-indicator to a single instance, perhaps some sort of #{asetsScreener.column1Visible}


          Best regards,

          Mark

          • 2. Dynamic columns visibility
            vali_iva

            Hi Mark,

             

            Thanks for the reply.

            Well thats the catch, I want for every column one different checkbox that sets the visibility. But I don't take the visibility from row-variable, I take it from column-variable in the second table : <rich:columns value="#{asetsScreener.indexes}" var="column" .

            It is true that in the first table those are rows. So to clarify, the rows in the first table are columns in the second table.

             

            So do you think is there a solution to get this thing done?

             

            Vali


            • 3. Dynamic columns visibility
              liuliu

              #{asetsScreener.comps} is a hashmap? his key is string?

              • 4. Dynamic columns visibility
                vali_iva

                Iep, that's right. It's key is a string name of the column.

                • 5. Dynamic columns visibility
                  liuliu

                  the 2 datatables in the same form?

                  • 6. Re: Dynamic columns visibility
                    vali_iva

                    Yes, the they are on the same form.

                    The code snippet is simplified but I atached the whole xhtml.

                    Thanks.

                    Vali

                    • 7. Dynamic columns visibility
                      vali_iva

                      I finnaly got it. All it needed was to put the tables in two different <a4j:form>. But I don't know why.

                       

                      An explanation from a proffesional would be highly appraciated. So we can better understand how RF works.

                       

                      Thanks

                       

                      Vali.

                      • 8. Dynamic columns visibility
                        ilya_shaikovsky

                        I finnaly got it. All it needed was to put the tables in two different <a4j:form>. But I don't know why.

                         

                        probably som other inputs in the form break the lifecycle at conversion/validation. You could check it easilly if will return single form by phasetracker or messages component.