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 there a way to have a fixed width per column on the <td> tag then align text to the right? #214

Open
marquipaul opened this issue Dec 3, 2020 · 4 comments

Comments

@marquipaul
Copy link

The goal
Screenshot from 2020-12-03 13-25-04

Best attempt
<tr>
<td width="5"> ${item.quantity}</td>
<td width="75"> ${this.wrapText(item)}</td>
<td width="20" align="right"> ${this.numberWithCommasR(this.totalPerItemList(item))} </td>
</tr>

The question
Is there a way to have a fixed width per column on the <td> tag then align text to the right. Currently i'm using the package to produce a tabular view for the product list for receipt printing with esc-pos-encoder and it is working fine but the problem is that the width of the column is not fixed and the expedted result on the printed receipt was not met and it should also align the price value to the right side.

If anyone have a solution for this please let me know. Thank you.

I'm using the package on the browser.

@KillyMXI
Copy link
Member

KillyMXI commented Dec 3, 2020

Hi, thanks for this question. Interesting use case.

Currently there is only an option to specify maxColumnWidth for tables. It will wrap anything that exceeds the given value but still keep columns as narrow as possible, which is not what you'd need for fixed text layout.

I had no intent to support deprecated HTML attributes, but I can see how it is useful in this case. And CSS is out of scope of this project anyway.

I will think though, whether I should read it from any cells or add support for colgroup and col and only take values from there.

I also think it might be useful to be able to make tables fill the wordwrap (aka the maximum total text width) without doing precise math on individual column widths (support percentage width for the table itself). But that will require to support both stretching narrow tables and shrinking wide tables...

I will try to add these, but I can't give an ETA.

@marquipaul
Copy link
Author

Hi, thank you for your response. I hope that this issue/question is helpful to make improvements to your package. I really appreciate the package it is very helpful and I hope you found a solution for this case. Thank you

@Sun3
Copy link

Sun3 commented Feb 25, 2021

Any updates on the Columns support?

Thank you.

@KillyMXI
Copy link
Member

KillyMXI commented Feb 25, 2021

@Sun3 Columns?

I was working on some part of this issue in December, until my laptop broke.
I've also discovered back then that I have to rewrite quite a lot of stuff to make it all work.
I need to revisit that branch and reevaluate my plans about it.

I started to work on this in hope it is a smaller, faster feature to implement. Since I was proven wrong, then either I have to scale down and see what minimal subset I can do reasonably quickly, or it moves down in my priority list - there are couple of big features I think more people will benefit from.

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

No branches or pull requests

3 participants