1
votes

I just upgraded from Primefaces 7.0 to Primefaces 8.0. I am seeing a duplicate header with a dataTable with StickyHeader inside a TabView when using the newer version. I did not see this behavior in 7.0. Isearched the forums and I did see a number of posts related to this issue. There is a solution posted by mertsincan on github (issue #1218) with a solution but it does not work. I downloaded the Primefaces showcase example and tried the solution posted by mertincan but it does not work. Below picture shows the behavior and I have an example file. I also checked all the link at github.com/primefaces/primefaces/… posted by Melloware on question Duplicate headers in primefaces data table

This is the same cars example from sticky on the showcase. Any direction/suggestions to fix this issue is very much appreciated. Thanks enter image description here Below is the viewfile

import java.io.Serializable;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;

import com.example.model.Car;
import com.example.service.CarService;

@Named
@ViewScoped
public class ScrollView implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = -1472033438497912037L;
    private List<Car> cars;

    @Inject
    private CarService service;

    @PostConstruct
    public void init() {
        cars = service.createCars(50);
    }

    public List<Car> getCars() {
        return cars;
    }

    public void setService(CarService service) {
        this.service = service;
    }

}

Below is the xhtml file. You can see the solution suggested by mertsincan on lines 10 and 11 in code : "mytabView.ui-tabs {position:static}

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"> 

<h:head>
<style type="text/css">
.myTabview.ui-tabs {
     position: static;
}

.noborders tr, .noborders td {
    background: none !important;
    border: none !important;
}

.negativeColor {
    color: red;
}

.ui-datagrid-no-border>.ui-datagrid-content {
    border: none !important;
}
</style>
</h:head> 
<body> 
    <p:tabView id="CarsTabView" dynamic="false" cache="true" styleClass="myTabview">
        <p:tab id="CarsTab" title="Cars">
            <p:dataTable var="car" value="#{scrollView.cars}" stickyHeader="true">
                <p:column headerText="Id">
                    <h:outputText value="#{car.id}" />
                </p:column>
                <p:column headerText="Year">
                    <h:outputText value="#{car.year}" />
                </p:column>
                <p:column headerText="Brand">
                    <h:outputText value="#{car.brand}" />
                </p:column>
                <p:column headerText="Color">
                    <h:outputText value="#{car.color}" />
                </p:column>
            </p:dataTable>
        </p:tab>
    </p:tabView>
</body> 
</html>
1
Are you using a specific theme? Investigated the differences in generated html and applied css between 7 and 8? - Kukeltje
The problem happens only when putting datatable in a tabview (PF 8), try adding this style .ui-tabs { -moz-transform: unset; -o-transform: unset; -webkit-transform: unset; transform: unset; } - WoAiNii
I tried adding the suggested style but I still see the same behavior. I was using the Nova-Colored scheme and I removed the theme and checked with other themes and it exhibits the same behavior. Is this a bug? - RXP
Which browser are you using? With Firefox 75, Chrome 81 (IE doesn't count ^^), removing trasform: scale(1) to ui-tabs solve the problem for me (I'm not using any theme). Test case - WoAiNii
@WoAiNii you are right this is already fixed for 8.0.2 by removing the transform: scale(1) See github.com/primefaces/primefaces/issues/5675 - Melloware

1 Answers

3
votes

This was introduced in PF 8.0 because of this ticket: https://github.com/primefaces/primefaces/issues/5429

Turns out zoom:1 was an old IE8 hack and since PF no longer supports IE8 we should not have converted it to transform: scale(1).

This will be fixed in PF Elite 8.0.2 with this ticket: https://github.com/primefaces/primefaces/issues/5675