[英]can I have <br> linebreaks in title of an existing html table?
(這是從 HTML 加載 Tabulator)
如果這些標題包含換行符,我似乎無法將列定義指向現有標題。
即這張table>tr>th
將不起作用
<th >Primary<br/>Permission List?</th>
和
"columns": [
{
"title": "Primary<br/>Permission List?"
},
...
有沒有辦法解決? 別名? 我假設field
屬性在這里沒有幫助。 列選項中的格式不同? 表格鏈接后可以修改<th>
HTML嗎?
如果不可能,也沒什么大不了的,只是檢查一下。
版本:tabulator-tables@5.4.2
您可以使用titleFormatter在標題單元格中顯示您喜歡的任何內容。
例如,在列定義中:
"columns": [
...,
{
title: "My<br>Multi<br>Line<br>Title",
titleFormatter: (cell) => this.myTitleFormatter(cell),
...,
}
然后是格式化程序 function:
private myTitleFormatter(cell) {
const splitChars = "<br>";
const cv = cell?.getValue() ?? "";
const splits = cv.split(splitChars);
if (splits.length > 1) {
const el = document.createElement('span');
el.appendChild(document.createTextNode(splits[0]));
splits.slice(1).forEach(s => {
el.appendChild(document.createElement('br'));
el.appendChild(document.createTextNode(s));
});
return el;
} else {
return cv
}
}
<br>
實際上不是 HTML,只是一個標記/分割點,因此您可以使用其他任何東西,比如“#$#”:
"My#$#Long#$#Title"
並將其用於格式化程序中的splitChars
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.