-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console][Table] Apply options/style to table cells #13370
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
Comments
Do you any other use case other than center a cell ? |
This issue is a generalization of #13368. The main objective is to have as much flexibility and features as an HTML table would provide us with. At one point I considered that the solution to the table problem would be to have php generate an html table which would then be given to the Thus the main points of interest are:
|
@tomzx in #13438, I used TableCell where we can can specify data for cell, 1- Introduce a new TableCellStyle: $table->addRow([new TableCell("data", ['style' => new TableStyleCell()]), 'data']); 2- add more option in table TableStyleCell: $cellOption = [
'rowspan' => 1,
'colspan' => 2,
'format' => '%s',
'align' => 'left',
];
$table->addRow([new TableCell("data", $cellOption), 'data']); @fabpot what would be your preferred way ? |
I also recently had a need to have odd/even table row colors or a way to individually color a row/cell. So 👍 for this. |
👍 |
I also recently had a need to add background color to some cells depending on the context. So 👍 for this. Is there any update? |
I think someone needs to implement it and submit a pull request. Sounds like an interesting feature to me. |
@fabpot , is it still needed? |
I think so :) |
So what would you prefer? TableCellStyle / options array as stated above or some:
|
@fabpot ping ) |
+1, Need availability for styling table cells. I'd prefer declarative definition (via array or TableCellStyle). |
+1 |
This PR was squashed before being merged into the 5.2-dev branch. Discussion ---------- [Console] added TableCellStyle | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #13370 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Added an opportunity to customize a table cell via TableCellStyle object. It can be used as ```php new TableCell( 'content', [ 'style' => new TableCellStyle([ 'align' => 'center', 'fg' => 'red', 'bg' => 'green', // or 'cellFormat' => '<info>%s</info>', ]) ] ) ``` See #13370 Commits ------- aff7628 [Console] added TableCellStyle
It would be nice if
Table
was able to be styled as much as a HTML table can.Use case: Center some cells
I think the way we can approach this with the current implementation is to add an optional
$options
parameter to the methods adding/setting rows.The array would look as such:
[ cellNumber => [ propertyA => value, propertyB => value, colspan => value, rowspan => value, align => left|center|right, format => '<info>%s</info>', ] ]
By using keyed cell number (for a single row), we can specify data for only specific cells (does not force the user to specify an empty array for each cell).
Any undefined property implies the default values for the table.
The text was updated successfully, but these errors were encountered: