How to add style class to p-dataTable row

前端 未结 3 1780
盖世英雄少女心
盖世英雄少女心 2021-01-08 01:30

We\'re using p-dataTable from PrimeNG 1.0.0-beta.16

I want to add a style to the row when a value is true. I figured it out how to do this with the cell, but I need

3条回答
  •  别那么骄傲
    2021-01-08 01:55

    rowStyleClass works a bit differently than you'd think; it takes a function as it's input, that returns a string (the CSS class name). It's listed in the PrimeNG DataTable docs.

    In my HTML I've got:

    
    

    In the component:

    lookupRowStyleClass(rowData: User) {
        return rowData.accountDisabled ? 'disabled-account-row' : '';
    }
    

    In a global CSS file:

    /* TODO: this should really be in the component's CSS file, but it doesn't seem to apply to the PrimeNG data table properly there */
    .disabled-account-row {
        /* TODO: first try this without '!important', but you might need it */
        color: silver !important;
    }
    

    If this doesn't help, you need to upgrade to a more recent version. PrimeNG 1.0.0 RC5 is out as of November 2016.

提交回复
热议问题