Data Table : changing background color of header row

UI Components for JSF
Post Reply
Manav
Posts: 8
Joined: 22 Nov 2011, 16:10

30 Nov 2011, 09:33

Hi,

Can we change the background color of datatable header rows. I tried using background-color property but in vain.
Thanks,
Manav

using PrimeFaces-2.2.1 - JSF2.0 - Tomcat6.0

User avatar
leventgny
Posts: 238
Joined: 24 May 2011, 16:49
Contact:

30 Nov 2011, 09:42

Try with more specific css selectors like;

Code: Select all

<p:dataTable styleClass="myTable" ... />

.ui-datatable.myTable th {
    background: red;
}
PrimeFaces Team Member

Manav
Posts: 8
Joined: 22 Nov 2011, 16:10

01 Dec 2011, 09:49

Hi,

Thanks for looking into it. But it doesn't work. The row bgcolor is still the default one - light grey.
Thanks,
Manav

using PrimeFaces-2.2.1 - JSF2.0 - Tomcat6.0

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

01 Dec 2011, 09:53

Check your css, your theme can overwrite with a background image.

paulg
Posts: 14
Joined: 09 May 2016, 22:41

17 May 2016, 02:39

I am having the same issue. I can not figure out how to change the background color of the headers or footers of a data table. Spplying the a style only chnges the color of a data cell, not a header cell.

Code: Select all

    <p-dataTable [value]="_countriesHC"
                 [rows]="5" [paginator]="true" [pageLinks]="3"
                 [responsive]="true" [stacked]="stacked">

        <p-column field="DisplayName" header="Country Name" sortable="true" style="background-color:rgba(255, 0, 0, 0.51);"></p-column>
        <p-column field="CountryId" header="Country Guid" style="background-color:rgba(0, 0, 255, 0.51);"></p-column>
        <p-column field="Abbreviation" header="Country Abbreviation" sortable="true" style="background-color:rgba(0, 128, 0, 0.53);"></p-column>


        <footer>
            <div class="ui-helper-clearfix" style="width:100%">
                <button pButton type="button" icon="fa-plus" iconPos="left" label="Add" style="float:left;" (click)="hello()"></button>
            </div>
        </footer>

    </p-dataTable>

Image


I have also not been able to figure out how to apply a different theme for PrimiNG to use either.

The docs say:

Code: Select all

<context-param>  
    <param-name>primefaces.THEME</param-name>  
    <param-value>bootstrap</param-value>  
</context-param>  
but does not say where to put this code. I am using the DataTable in a MVC.Net application running Angular2 on the frontEnd, inside an angular2 component template.

paulg
Posts: 14
Joined: 09 May 2016, 22:41

17 May 2016, 03:32

leventgny wrote:Try with more specific css selectors like;

Code: Select all

<p:dataTable styleClass="myTable" ... />

.ui-datatable.myTable th {
    background: red;
}

Since it is apparent you are using some attribute names other than the standard CSS attributes, such as "background" instead of "background-color", where are all these redefined CSS attributes defined?


Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 35 guests