Dynamic columns visibility
vali_iva May 18, 2011 8:53 AMHi, 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
 
     
     
    