刷新后保持已排序的extendedDataTable richfaces

时间:2013-10-08 10:38:27

标签: sorting jsf richfaces

我正在使用richfaces,我有一个extendedDataTable表,在表格中显示行后,我做了一个排序。之后我会onRowDblClick显示更多信息。然后我的问题是当我回到主表时,表没有排序。我的问题是:

  1. 其中richfaces进行排序;
  2. 当表在客户端排序时,是否可以对服务器端的列表进行排序;
  3. 是否可以将排序后的列表保存在Java脚本中。

     <rich:extendedDataTable id="EnteterecpGlo" value="#{EnteteReceptionsGlobale.enteteReceptions}" var="receptionList" sortMode="single" rowKeyVar="rkv" style="align:left;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;" width="100%" height="365" rows="16" selectionMode="single" onRowDblClick="if(#{receptionList.numintrec}!='undefined') {rechercherdetail(#{receptionList.numintrec}); }" enableContextMenu="true">
                <rich:column width="8%"   sortBy="#{receptionList.selection}">
                  <center>
                    <f:facet name="header">
                        <h:outputText id="fopt_id_select" value="Selection" />
                    </f:facet>                  
                    <h:selectBooleanCheckbox onclick="takeselection(#{receptionList.numintrec})" value="#{receptionList.selection}"  >
                    </h:selectBooleanCheckbox>                                
                  </center>  
                </rich:column>
    
                <rich:column id="id_col_cod_ext_rec_vgr"  width="8%"
                    sortBy="#{receptionList.numextrec}" label="N&#186; reception "  >
    
                    <f:facet id="id_fac_cod_ext_rec_vgr" name="header">
                        <h:outputText id="fopt_cod_ext_rec_vgr" value="N&#186; Recep">                              
                            <rich:toolTip for="fopt_cod_ext_rec_vgr" value="N&#186; Reception"/>
                        </h:outputText>
                    </f:facet>
                    <h:outputText id="copt_cod_ext_rec_vgr" value="#{receptionList.numextrec}" />
                </rich:column>
    
                <rich:column id="id_col_num_com_vgr"  width="8%"
                    sortBy="#{receptionList.numcommande}" label="N&#186; Commande" >
                    <f:facet id="fid_fac_num_com_vgr" name="header">
                        <h:outputText id="fopt_num_com_vgr" value="N&#186; Cmde" >                              
                            <rich:toolTip for="fopt_num_com_vgr" value="N&#186; Commande"/>
                        </h:outputText>
                    </f:facet>
                    <h:outputText id="opt_num_com_vgr" value="#{receptionList.numcommande}" >                           
                    </h:outputText>
                </rich:column>
    
                <rich:column id="id_col_bl_vgr"  width="7%"
                    sortBy="#{receptionList.numbonliv}" label="N&#186; BL" >
                    <f:facet id="id_fac_bl_vgr" name="header">
                        <h:outputText id="fopt_bl_vgr" value="N&#186; BL" >                             
                            <rich:toolTip for="fopt_bl_vgr" value="N&#186; Bon de Livraison"/>
                        </h:outputText>
                    </f:facet>
                    <h:outputText id="copt_bl_vgr" value="#{receptionList.numbonliv}" />
                </rich:column>
    
                <rich:column id="id_col_site_vgr"  width="4%"
                    sortBy="#{receptionList.site}" label="Site">
                    <f:facet id="fid_fac_site_vgr" name="header">
                        <h:outputText id="fopt_site_vgr" value="Site" />
                    </f:facet>
                    <h:outputText id="opt_site_vgr" value="#{receptionList.site}" />
                </rich:column>      
    
    
                <rich:column id="id_col_libsite_vgr"  width="17%" 
                    sortBy="#{receptionList.libsite}" label="Libelle">
                    <f:facet id="fid_fac_libsite_vgr" name="header">
                        <h:outputText id="fopt_libsite_vgr" value="Libelle" />
                    </f:facet>
                    <h:outputText id="opt_libsite_vgr" value="#{receptionList.libsite}" />
                </rich:column>      
    
    
                <rich:column id="id_col_etatfac_vgr"  width="8%" 
                    sortBy="#{receptionList.etatfacture}" label="Etat Facture">
                    <f:facet id="fid_fac_etatfac_vgr" name="header">
                        <h:outputText id="fopt_etatfac_vgr" value="Etat Facture" />
                    </f:facet>
                    <h:outputText id="opt_etatfac_vgr" value="#{receptionList.etatfacture}" />
                </rich:column>  
    
                <rich:column id="id_col_numtraite_vgr"  width="10%"
                    sortBy="#{receptionList.numtraite}" label="N&#186; Reglement">
                    <f:facet id="fid_fac_numtraite_vgr" name="header">
                        <h:outputText id="fopt_numtraite_vgr" value="N&#186; Reglement" />
                    </f:facet>
                    <h:outputText id="opt_numtraite_vgr" value="#{receptionList.numtraite}" />
                </rich:column>      
    
                <rich:column id="id_col_daterec_vgr"  width="8%" 
                    sortBy="#{receptionList.datereception}" label="Date Reception">
                    <f:facet id="fid_fac_daterec_vgr" name="header">
                        <h:outputText id="fopt_daterec_vgr" value="Date Recep" >                                
                            <rich:toolTip for="fopt_daterec_vgr" value="Date Reception"/>
                        </h:outputText>
                    </f:facet>
                    <h:outputText id="opt_daterec_vgr" value="#{receptionList.datereception}" >
                    <f:convertDateTime id="fcvt_daterec_vgr" pattern="dd/MM/yyyy"/>
                    </h:outputText>
                </rich:column>      
    
                <rich:column id="id_col_datecmd_vgr"  width="8%"
                    sortBy="#{receptionList.datecommande}" label="Date Commande">
                    <f:facet id="fid_fac_datecmd_vgr" name="header">
                        <h:outputText id="fopt_datecmd_vgr" value="Date Cmde" >                             
                            <rich:toolTip for="fopt_datecmd_vgr" value="Date Commande"/>
                        </h:outputText>
                    </f:facet>
                    <h:outputText id="opt_datecmd_vgr" value="#{receptionList.datecommande}" >
                    <f:convertDateTime id="fcvt_datecmd_vgr" pattern="dd/MM/yyyy"/>
                    </h:outputText>
                </rich:column>      
    
                <rich:column id="id_col_ville_vgr"  width="10%"
                    sortBy="#{receptionList.ville}" label="ville">
                    <f:facet id="fid_fac_ville_vgr" name="header">
                        <h:outputText id="fopt_ville_vgr" value="ville" />
                    </f:facet>
                    <h:outputText id="opt_ville_vgr" value="#{receptionList.ville}" />
                </rich:column>
    
                <rich:column id="id_col_concom_vgr"  width="6%"
                    sortBy="#{receptionList.contracommercial}" label="Contrat Commercial">
                    <f:facet id="fid_fac_concom_vgr" name="header">
                        <h:outputText id="fopt_concom_vgr" value="Contrat" >                                
                            <rich:toolTip for="fopt_concom_vgr" value="Contrat Commercial"/>
                        </h:outputText>
                    </f:facet>
                    <h:outputText id="opt_concom_vgr" value="#{receptionList.contracommercial}" />                  
                </rich:column>
    
                <rich:column id="id_col_codefrs_concom_vgr" width="10%"   rendered="#{Login.userprofil==0}"
                    sortBy="#{receptionList.codefrs}" label="Code Fourn">
                    <f:facet id="fid_fac_codefrs_concom_vgr" name="header">
                        <h:outputText id="fopt_codefrs_concom_vgr" value="Code Fourn" >                             
                            <rich:toolTip for="fopt_codefrs_concom_vgr" value="Code Fournisseur"/>
                        </h:outputText>
                    </f:facet>
                    <h:outputText id="opt_codefrs_concom_vgr" value="#{receptionList.codefrs}" />
                </rich:column>
    
                <rich:column id="id_col_libfrs_concom_vgr" width="10%"  rendered="#{Login.userprofil==0}"
                    sortBy="#{receptionList.libfrs}" label="Lib Fourn">
                    <f:facet id="fid_fac_libfrs_concom_vgr" name="header">
                        <h:outputText id="fopt_libfrs_concom_vgr" value="Lib Fourn" >                               
                            <rich:toolTip for="fopt_libfrs_concom_vgr" value="Libelle Fournisseur"/>
                        </h:outputText>
                    </f:facet>
                    <h:outputText id="opt_libfrs_concom_vgr" value="#{receptionList.libfrs}" />
                </rich:column>                                                              
    </rich:extendedDataTable>
    

1 个答案:

答案 0 :(得分:0)

使用数据表的tableState属性来保持支持bean中表的状态。那么你将拥有的是:

<rich:extendedDataTable id="EnteterecpGlo" value="#{EnteteReceptionsGlobale.enteteReceptions}" var="receptionList" tableState="#{EnteteReceptionsGlobale.savedState}" sortMode="single"

savedState应该对应String支持bean变量。显然,为了实现这一点,变量必须保持在持久的源中,所以绝对不是@RequestScoped bean