如何在根据Primefaces中bean的某个字段对行进行分组的dataTable中呈现行?

时间:2018-02-21 19:11:39

标签: primefaces

我对Primefaces很陌生,而且我很难理解它是如何工作的。我正在尝试创建一个数据表,该数据表将显示一系列根据其中一个字段(区域)分组的记录,其中一个标题行指示其下方行的区域。 Primefaces中有一个标签(自6.0.11开始)," p:headerRow",但它对我的版本Primefaces 5.3不可用。 "列中还有一个属性"标签," groupRow",但它也不适用于我的版本。想到的一个想法是使用条件标题行,它将显示以下行的区域值,具体取决于区域是否已更改(如果不是,则不显示标题;如果是,则显示它)。我想使用变量" areaActual"跟踪正在渲染的区域,与表格中下一行的区域进行比较。我希望我清楚......但是变量似乎不起作用,标题行不会显示为标题(如果我删除"渲染"条件)。请帮忙!

这是xhtml。:

<h:panelGroup id="pgbody" styleClass="backBeanChangeBody" rendered="#{informacionpersonal$kardex.existe}">
        <p:dataTable id="dataTablePrincipal" 
                     style="height:100%;width:100%" value="#{informacionpersonal$kardex.listaKardex}" var="currentRow" rows="10"
                     paginator="true" rowsPerPageTemplate="10,15,20,25,30" reflow="true" >
            <p: rendered="#{!currentRow.area eq areaActual}">
                <p:column id="encabezado" colspan="7">
                    <p:outputLabel value="#{areaActual}" />
                </p:column>
            </p:row>
            <ui:param name="areaActual" value="#{currentRow.area}" />
            <p:row>
                <p:column id="column3"  sortBy="#{currentRow.espAsignatura}">
                    <p:outputLabel id="outputText5" value="#{currentRow.espAsignatura}"/>
                    <f:facet name="header">
                        <p:outputLabel value="Asignatura"/>
                    </f:facet>
                </p:column>
                <p:column id="column5" sortBy="#{currentRow.espPeriodoescolar}">
                    <p:outputLabel  value="#{currentRow.espPeriodoescolar}" />                    
                    <f:facet name="header">
                        <p:outputLabel value="Periodo escolar"/>
                    </f:facet>
                </p:column>
                <p:column id="column6" sortBy="#{currentRow.creditos}">
                    <p:outputLabel  value="#{currentRow.creditos}" />                    
                    <f:facet name="header">
                        <p:outputLabel value="Créditos"/>
                    </f:facet>
                </p:column>
                <p:column id="column7" sortBy="#{currentRow.espTipoevaluacion}">
                    <p:outputLabel  value="#{currentRow.espTipoevaluacion}" />                    
                    <f:facet name="header">
                        <p:outputLabel value="Tipo de evaluación"/>
                    </f:facet>
                </p:column>
                <p:column id="column12" sortBy="#{currentRow.calificacion}">
                    <p:outputLabel  value="#{currentRow.calificacion}"/>
                    <f:facet name="header">
                        <p:outputLabel value="Calificación"/>
                    </f:facet>
                </p:column>      
            </p:row>
        </p:dataTable>
    </h:panelGroup>

这是豆子:

@ManagedBean(name = "informacionpersonal$kardex")
@ViewScoped
public class kardex extends FacesBean implements Serializable {
private int __placeholder;
private void _init() throws Exception {
    selectOneMenu1DefaultItems.setItems(new String[]{"10", "15", "20", "25", "30"});
}

private FormaModal formaModal = (FormaModal) getValue("#{plantilla.formaModal}");
private Boolean notselectedrow = true;
private DefaultSelectionItems selectOneMenu1DefaultItems = new DefaultSelectionItems();

public DefaultSelectionItems getSelectOneMenu1DefaultItems() {
    return selectOneMenu1DefaultItems;
}

public void setSelectOneMenu1DefaultItems(DefaultSelectionItems dsi) {
    this.selectOneMenu1DefaultItems = dsi;
}

public Boolean getNotselectedrow() {
    return notselectedrow;
}

public void setNotselectedrow(Boolean notselectedrow) {
    this.notselectedrow = notselectedrow;
}

private TableListDataModel tabla;

public TableListDataModel getTabla() {
    return tabla;
}

public void setTabla(TableListDataModel tabla) {
    this.tabla = tabla;
}

// </editor-fold>
private Persona alumno;
private Boolean existe;
private List<VEscHistoriaacademica> listaKardex;

public kardex() {
}
@PostConstruct
public void init() {
    try {
        _init();
    } catch (Exception e) {
        log("Page1 Initialization Failure", e);
        throw e instanceof FacesException ? (FacesException) e : new FacesException(e);
    }
    listaKardex = new ArrayList<VEscHistoriaacademica>();
}

@PreDestroy
public void destroy() {
}
protected ApplicationBean1 getApplicationBean1() {
    return (ApplicationBean1) getBean("ApplicationBean1");
}
protected Controlador getControlador() {
    return (Controlador) getBean("Controlador");
}
public Persona getAlumno() {
    return alumno;
}
public void setAlumno(Persona alumno) {
    this.alumno = alumno;
    listaKardex = new ArrayList<VEscHistoriaacademica>();
    listaKardex.clear();
    listaKardex = getControlador().findByAlumno(alumno.getId());
    existe = !listaKardex.isEmpty();
}
public List<VEscHistoriaacademica> getListaKardex() {
    return listaKardex;
}
public void setListaKardex(List<VEscHistoriaacademica> listaKardex) {
    this.listaKardex= listaKardex;
}
public Boolean getExiste() {
    return existe;
}
public void setExiste(Boolean existe) {
    this.existe = existe;
}
}

谢谢!

0 个答案:

没有答案