-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Add non-auto column width functionality #17761
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
Conversation
I'm 👍 for the idea of this pull request, but I have some comments and questions.
-->setColumnFixedWidth(0, 15)
+->setColumnWidth(0, 15);
->setColumnWidth(0, 15)
->setColumnWidth(1, 'auto')
->setColumnWidth(2, 25);
->setColumnWidth(3, 'auto')
$table
->setHeaders(array('ISBN', 'Title', 'Author', 'Price'))
->setColumnWidths(array('13', 'auto', 'auto', '5'))
->setRows(array(
// ...
)) |
Thanks for your input.
|
…xedWidth to columnWidth; implemented setColumnWidths; implemented 'auto' as valid value
@akeeman Can you submit a documentation pull request (on symfony/symfony-docs) to document this new feature? Can you also add a small note about this in the component CHANGELOG? Thanks. |
@fabpot Was it intended to close here? |
I did already provide the documentation, but as this PR is closed cannot provide the change log line along with this PR. diff --git a/src/Symfony/Component/Console/CHANGELOG.md b/src/Symfony/Component/Console/CHANGELOG.md
index 6d4e0f9..df37640 100644
--- a/src/Symfony/Component/Console/CHANGELOG.md
+++ b/src/Symfony/Component/Console/CHANGELOG.md
@@ -5,6 +5,7 @@ CHANGELOG
-----
* added truncate method to FormatterHelper
+ * added setColumnWidth(s) method to Table
2.8.3
----- |
The code and change log line are now given in this PR, where some documentation is provided here. Let me know if there is any further feedback. If not, I consider this PR finished. |
(Woops, wrong button) |
'Width "%d" is not a valid column width for column %d. Expected width > 0 or \'auto\'.', | ||
$width, | ||
$columnIndex | ||
)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be on one line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing "
around the decons %d
Can you also change 'auto'
by "auto"
?
Given that the column width is the maximum value over the cell's content width and the int casted column width that is given to the setColumnWidth or setColumnWidths method, the values -1, 0 or "auto" will result in the same behavior. |
I still think that "auto" support should be removed. Mixing strings with integer is not a good idea IMO. |
And it's ugly when using tools such as |
It was a wish of your fellow member. However, it has been removed as it keeps the whole thing simpler anyway. |
} | ||
|
||
/** | ||
* Set the minimum width of all columns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sets
Thank you @akeeman. |
This PR was merged into the master branch. Discussion ---------- [Console] Add columns width setter documentation Documentation for symfony/symfony#17761 Commits ------- 097fb65 remove support for "auto" 50a74fb Add columns width setter documentation
Be able to fix a columns width in a console table (i.e. set a columns width beforehand).
When a column's contents exceed the given column width, it will stretch.
Very useful, for instance, when one wants to display multiple tables that are separated from each other, but still want to align their columns.