jsf - Primefaces columToggler losing effect on filters -


i have lazy datatable filters, have option of toggling columns , works fine on first time, if remove let's 3 columns , make new filter columtoggler keep's state of selection , headers of columns invisible well, values come again... sounds little weird explaining, i'll illustrate it.

original

so after columns selected get:

filtered

but when filtering or ordering on datatable get: messedup

i'm declaring columntoggler following way:

                <f:facet name="header">                     lista de csrs                      <p:commandbutton id="toggler" update="@form" type="button"                         value="columns" style="float:right" icon="ui-icon-calculator" />                     <p:columntoggler datasource="csrtable" trigger="toggler" />                 </f:facet> 

if other information needed omitted please tell me.

i've found answer on primefaces blog: http://blog.primefaces.org/?p=3341

i changed columtoggler to:

<p:columntoggler datasource="csrtable" trigger="toggler" >                         <p:ajax event="toggle" listener="#{csrbean.ontoggle}" />                     </p:columntoggler> 

and on bean added following:

private list<boolean> colunas; //getters , setters  public void init(){         setcolunas(arrays.aslist(true, true, true, true, true, true, true, true, true, true, true)); }  public void ontoggle(toggleevent e) {         getcolunas().set((integer) e.getdata(), e.getvisibility() == visibility.visible);     } 

then added rendered state on each colum:

<p:column headertext="numero" sortby="#{csr.numero}"                     filterby="#{csr.numero}" rendered="#{csrbean.colunas[0]}"> 

and done.


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -