Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to assign background color to a table cell? #29

Closed
ynfiesta opened this issue May 19, 2014 · 15 comments
Closed

Is it possible to assign background color to a table cell? #29

ynfiesta opened this issue May 19, 2014 · 15 comments
Assignees

Comments

@ynfiesta
Copy link

Is it possible to assign background color to a table cell?

thanks, library is awesome

@ironmanBlue14
Copy link

Hi, I try to use this library and it's very simple and fun.
But I need to set a style with background color to a table cell..Is it possible?

thanks

@bpampuch
Copy link
Owner

Not yet

Sorry, I've been very busy during last 3 weeks, I'll get back to pdfmake next week.

@bpampuch bpampuch added this to the more building blocks milestone May 21, 2014
@bpampuch bpampuch self-assigned this May 21, 2014
@ironmanBlue14
Copy link

Ok, thanks for your answer!

@ironmanBlue14
Copy link

Hi, sorry, but I need to use this feature.
When do you think will be implemented?
I need this information because I may find another library...

Thanks

@BobbieBarker
Copy link

I would like to add that I could really use this feature as well.

@onbermejo
Copy link

Yes, It could be really useful. And It would be great not only to a cell, also to a complete row. Thanks

@yelouafi
Copy link
Contributor

yelouafi commented Sep 3, 2014

Needed that for my app so i added some lines of code to tableProcessor.js;
You use it by adding another function in the layout definition

var layout = { 
    hLineWidth: function(i, node) { ... }, 
    vLineWidth: function(i, node) { ... }, 
    hLineColor: function(i, node) { ... }, 
    vLineColor: function(i, node) { ... }, 
    //you just return null for the rest
    fillColor: function(row, col, node) { return row > 0 && row % 2 ? 'yellow' : null; }
} 

here is a plunker to test

Not sure if that will fit well the rest o library but i tested it and it works well (even against variable border sizes)

@onbermejo
Copy link

Nice work yelouafi.
Is it possible to assign a cell color inside the code? For example:

[{ text: 'Cell text', style: 'headerTable', colSpan:2, fillColor:'red'},{}]

@martingrasso
Copy link

Hmm, I'm not seeing this working in Chrome on plunker. Is this this working?

@yelouafi
Copy link
Contributor

Sorry I was fixing some issues and did some branching reset
Plunker should be working fine now
BTW i changed the usage to a more natural fillColor style property as @onbermejo commented;

[{ text: ...., fillColor: 'yellow'}]

And since it's style property you can also use the library styling capabilities (style dictionaries, style overrides)

var docDef = {
    .....    
    [{ text: ....,  style: 'myCell'}]
   .....
   styles: {
     myCell: { fillColor: 'yellow' }
   }

@onbermejo
Copy link

It is working very well!
Thank you @yelouafi

@yelouafi :Before I implement it on my production server, I would like to know if this new library is the same as the original, only with the change of the fillColor? I have been comparing them and there are several changes.

@bpampuch : Are you going to implement this changes to your original file?

It would be great not to divide the project,

Thanks.

@yelouafi
Copy link
Contributor

@onbermejo the only changes are (the master branch includes also the latest builds)

you can also checkout the tableCellFillColor and run your own builds locally

BTW you may also find it useful to merge the textDecorator

And just a last EDIT: i don't intend to create a new library from this fork; all those features are intended to enhance the main library (which i find awesome to have in the node.js archipel).

as for the integration into the main library i already made this pull requests #82 and #79;

@martingrasso
Copy link

Thanks, yelouafi.

I just wasn't sure if I was doing something incorrect at the time or using an unsupported

I appreciate your efforts on this project. You are doing some pretty cool things.

@bpampuch
Copy link
Owner

PR has been merged

@JulianHidalgo
Copy link

Hi
I'd like to create a table with alternating background colors for each row. yelouafi's original approach with the table layout would have worked for me, but I see the fillColor property is now a part of the cell's style itself, which is also practical, but not so handy for what I want. Is there any way to do this without setting a style for each row on my code? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants