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

Add an attribute on a column #13

Closed
cedrticgayte opened this issue Oct 25, 2024 · 13 comments
Closed

Add an attribute on a column #13

cedrticgayte opened this issue Oct 25, 2024 · 13 comments

Comments

@cedrticgayte
Copy link

Hello,

I want to add the With attribute on a column. I did not find the method to do this. Do you have an example of code?

regards

@ay4t
Copy link

ay4t commented Oct 27, 2024

i think you can use like this

$table->addCellAttributes('row_name', 'col_name', [
        'style' => 'font-size: 1rem; background: #f6ffb0;'
    ]);

@cedrticgayte
Copy link
Author

Thanks for this feedback, it doesn't work :Uncaught Error: Call to undefined method Donquixote\Cellbrush\Table\Table::addCellAttributes()

@ay4t
Copy link

ay4t commented Oct 27, 2024

Oh sorry, this issue has been around for a long time and the repository owner never responded and updated. Some people have also tried to do a pull request but no response.

I also provide a similar repository that I adapted from this repository and there are some additions that might help in the future but I have not included detailed documentation.

You can try to clone from my repository ay4t/htmltable there I have added the addCellAttributes() function

@donquixote
Copy link
Owner

Hi
I have not touched this package in a long time, and also have no active use case.
Before I deal with the open PRs, now I want to set up CI with github actions first.

This used travis CI in the past, but I don't even remember how it works..

@donquixote
Copy link
Owner

As for the specific request:
I wonder why you need an attribute, instead of doing something with css..
but I suppose it is not wrong to have the option at least.

@ay4t
Copy link

ay4t commented Oct 27, 2024

This repository is awesome, I am very grateful for this library. In my case dealing with reports with PDF output, Because the company I work for requires PDF output. custom column styles are sometimes very necessary. I have tried to use CSS but it didn't work, maybe because I did it wrong but with custom style on the column it makes the display in pdf perfect

@donquixote
Copy link
Owner

donquixote commented Oct 27, 2024

@cedrticgayte

I want to add the With attribute on a column. I did not find the method to do this. Do you have an example of code?

Can you post the desired html output?
You say you want the attribute "on a column", would this mean on the respective cell of every row?

Other parts of this discussion and open PRs talk about attributes for a specific cell, but it seems you want to target the entire column.

- - x -
- - x -
- - x -

vs

- - - -
- - x -
- - - -

@donquixote
Copy link
Owner

See this PR, #9
I left some comments there.
I think I would go for setCellAttribute($row, $col, $name, $value).

donquixote added a commit that referenced this issue Oct 27, 2024
Issue #13: Let TableSection rely on ColumnClassesTrait.
@donquixote
Copy link
Owner

See

Please help testing and reviewing!

We need to be careful with changes to interfaces, these can break existing implementations that implement these interfaces.
So perhaps these need a new major version? Not sure.

@donquixote
Copy link
Owner

@ay4t

custom column styles are sometimes very necessary.

If this is about styles, do we need special handling for them?
E.g. ->addStyle('width', '100px');, instead of ->setAttribute('style', '100px');.
This would allow merging styles from different sources, e.g. column style + cell style.

I have tried to use CSS but it didn't work, maybe because I did it wrong

I have done html to pdf in the past.
There are php packages which do it, or you can let your headless chrome/chromium do it.
In both cases, in my experience, CSS did work.
The main problem I faced was with paging, an support for the print css.
Maybe you do face problems with specific selectors..

@cedrticgayte
Copy link
Author

Thanks for the feedback and for your component which is great.

My code only requires that I add attributes to columns enbtieere and/or cells. My code requires:

  • that I add an attribute such as Width to a column
  • that I add ids to cells

setCellAttribute($row, $col, $name, $value). would be ideal

donquixote added a commit that referenced this issue Oct 31, 2024
donquixote added a commit that referenced this issue Oct 31, 2024
…-interface-changes

Issue #13: Add setColAttribute(), without changing interfaces.
@donquixote
Copy link
Owner

Everything merged and released as 1.1.0.

@donquixote
Copy link
Owner

This repository is awesome, I am very grateful for this library.

Thanks for the feedback and for your component which is great.

You could blog about it and link to it :)
For me, if I see more people using it, it gives motivation to maintain and improve it.
But no pressure.

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