admin管理员组文章数量:1026463
I want to set the row height for all the rows in my table. I am currently specifying my styles like this:
table: {
widths: ['33%', '34%', '33%'],
heights: [40, 40],
headerRows: 1,
That works very well if I have a known amount of rows, in this case, the first row and the table header get the height of 40. Everything underneath will fall back to the default height since I didn't specify anything different.
If I, however, have a table with a lot of rows or like in my case a table where the row count is dynamic, it is a tedious task to write each height into the object.
Is there any better way of applying styles to all rows?
I want to set the row height for all the rows in my table. I am currently specifying my styles like this:
table: {
widths: ['33%', '34%', '33%'],
heights: [40, 40],
headerRows: 1,
That works very well if I have a known amount of rows, in this case, the first row and the table header get the height of 40. Everything underneath will fall back to the default height since I didn't specify anything different.
If I, however, have a table with a lot of rows or like in my case a table where the row count is dynamic, it is a tedious task to write each height into the object.
Is there any better way of applying styles to all rows?
Share Improve this question asked Feb 8, 2022 at 9:14 Luke_KSLuke_KS 1833 silver badges16 bronze badges2 Answers
Reset to default 3You can set the same height for all rows by assigning to "heights" a number instead of an array:
table: {
widths: ['33%', '34%', '33%'],
heights: 40,
headerRows: 1,
body: [...]
}
Alternatively, you could dynamically generate an array of the right length in JavaScript. This is more cumbersome, but it would allow you to specify different heights for different rows in a programmatic way.
Look at the playground here for more examples.
You can set padding in top and bottom. It is so handly, you can also set padding for specific row(s).
table: {
widths: ['33%', '34%', '33%'],
headerRows: 1,
body: [...]
},
layout: {
paddingTop: function (i, node) {
return 5;
//return (i === node.table.widths.length - 1) ? 5 : 5;
},
paddingBottom: function (i, node) {
return 5;
//return (i === node.table.widths.length - 1) ? 5 : 5;
}
}
I want to set the row height for all the rows in my table. I am currently specifying my styles like this:
table: {
widths: ['33%', '34%', '33%'],
heights: [40, 40],
headerRows: 1,
That works very well if I have a known amount of rows, in this case, the first row and the table header get the height of 40. Everything underneath will fall back to the default height since I didn't specify anything different.
If I, however, have a table with a lot of rows or like in my case a table where the row count is dynamic, it is a tedious task to write each height into the object.
Is there any better way of applying styles to all rows?
I want to set the row height for all the rows in my table. I am currently specifying my styles like this:
table: {
widths: ['33%', '34%', '33%'],
heights: [40, 40],
headerRows: 1,
That works very well if I have a known amount of rows, in this case, the first row and the table header get the height of 40. Everything underneath will fall back to the default height since I didn't specify anything different.
If I, however, have a table with a lot of rows or like in my case a table where the row count is dynamic, it is a tedious task to write each height into the object.
Is there any better way of applying styles to all rows?
Share Improve this question asked Feb 8, 2022 at 9:14 Luke_KSLuke_KS 1833 silver badges16 bronze badges2 Answers
Reset to default 3You can set the same height for all rows by assigning to "heights" a number instead of an array:
table: {
widths: ['33%', '34%', '33%'],
heights: 40,
headerRows: 1,
body: [...]
}
Alternatively, you could dynamically generate an array of the right length in JavaScript. This is more cumbersome, but it would allow you to specify different heights for different rows in a programmatic way.
Look at the playground here for more examples.
You can set padding in top and bottom. It is so handly, you can also set padding for specific row(s).
table: {
widths: ['33%', '34%', '33%'],
headerRows: 1,
body: [...]
},
layout: {
paddingTop: function (i, node) {
return 5;
//return (i === node.table.widths.length - 1) ? 5 : 5;
},
paddingBottom: function (i, node) {
return 5;
//return (i === node.table.widths.length - 1) ? 5 : 5;
}
}
本文标签: javascriptpdfmake How to set the height for all rowsStack Overflow
版权声明:本文标题:javascript - pdfmake: How to set the height for all rows? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745637774a2160554.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论