-
Notifications
You must be signed in to change notification settings - Fork 45
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
Support for multiple header rows #328
Comments
This is supported presently as it's merely a matter of adding a row at the beginning and optionally customizing the style. This isn't well documented, so I'll leave this open as something that can be added to the docs. For now, here is an example: const Table = require('.');
const colors = require('@colors/colors');
const table = new Table({
head: [{ content: 'Users', colSpan: 4, hAlign: 'center' }],
});
table.push(
// Subhead row with custom style
['First', 'Last', 'Email', 'Phone'].map((content) => ({ content: colors.bold(content) })),
['Jane', 'Doe', 'Jane.Doe@example.com', '555-867-5309'],
['John', 'Doe', 'John.Doe@example.com', '555-867-5310'],
);
console.log(table.toString()); Outputs: |
The downside to the above example is that it requires adding It would be ideal if colors was exposed through the Table interface so that it could be used directly: Eg. ['First', 'Last', 'Email', 'Phone'].map((content) => ({ content: Table.colors.bold(content) })), Note: This doesn't presently work. |
Gotcha. I'm already using Perhaps Updating the constructor to allow specifying additional head rows at time of instantiation. const table = new Table(
{
head: [
{ content: 'Users', colSpan: 4, hAlign: 'center' }, // row 1
['First', 'Last', 'Email', 'Phone'] // row 2
],
}
); Thanks for the help! |
Hello,
Does cli-table3 support multiple header rows? For example:
If so, can you point me to some documentation for this?
Thanks!
The text was updated successfully, but these errors were encountered: