Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to highlight specific rows while printing data from the jquery data table. I added a class to those rows by createdRow and added some CSS style to that class. Now I want to keep that styling on those rows while printing.

https://i.stack.imgur.com/hcl4w.png[^]

In the image, you can see some rows have a background color. I just want to keep that while printing data.

What I have tried:

The code I've used to add class
JavaScript
"createdRow": function (row, data, dataIndex) {
    var date = new Date(data.dateOfReg);
    var days = datediff(date, new Date());

    if (days >= 30 && parseInt(data.received) < 2000 && parseInt(data.payment) >= 2000) {
       $(row).addClass('d-flag');
    }    
}
Posted
Comments
Richard Deeming 11-Oct-22 6:43am    
Most browsers don't print background colours by default. You'll need to get your users to change their browser's printer settings to enable that.

Beyond that, you'll need to double-check that your classes aren't defined in a @media (screen) { ... } rule, which would prevent them from applying to the print layout.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900