PDF style
PDF style
Rich_Walker
Posts: 9Questions: 3Answers: 0
Is it possible to change the cell background colour if its a negative value or as minus symbol?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @Rich_Walker ,
Yep, take a look at this example here : it changes the age column to be blue if it's under 40!
Hope that helps,
Cheers,
Colin
@colin How would you modify the code to look through every column in a table
Or every cell in a defined range, say column 3-8?
Hi @Jokris,
To get the range, I'd keep it simple, just have it in a loop, something like:
Then, for all columns, just widen that loop.
Cheers,
Colin
Hi @colin This was going to be my next question. I have put your snippet in but can't create the pdf. http://live.datatables.net/livabosi/1/edit & haven't got any errors.
Is it possible to get it to change the footer color aswell?
Thanks in advance.
Rich
Hi Rich,
There is a console error, but it is vague - the problem is because you're using the test data, which only has 6 columns, and you're trying to scan 8 of them. That code I sent was more of an example of what could be done, rather than one to use as gospel.
Cheers,
Colin
Change
column <= 8;
to
column <= 5;
to get your PDF from the example. That should explain how to fix your own code
@colin or @tangerine
I am trying to apply it to this table stored in a database which doesn't have any TD tags. I can print the PDF but nothing is colored. Say I want to add background color to all cells on table below below with words 'Accountant or 'Edinburgh.
Following code is added after extend: 'pdfHtml5', text: 'PDF',
Still cant get it to work
I think you need to just look at that code, and debug it.
Two obvious things stand out,, that first
for
loop is suspect:You're making
column
an integer, and then testingcolumn.length
, so that's definitely wrong.And so is the second:
You've got the variable
age
from my example, which doesn't exist in your code.