单元格 jquery-bootgrid 中的换行符
Line break in cell jquery-bootgrid
有一种方法可以使用 jquery-bootgrid 使单元格内的 <br>
可见吗?因为 <br>
的渲染不可见。
我的理解是你想在你的数据中添加一个换行符,像这样,
在功能列中,我传递了一个数组,它使用 <br>
在单独的行中显示每个项目
为此您可以创建一个自定义转换器,
http://www.jquery-bootgrid.com/Documentation#converters
您可以在初始化 BootGrid 时创建转换器 Table
var dt = $('#myTable').bootgrid({
//.......... Other Options
converters: {
listDisplay: {
from: function(value) {
return value;
},
to: function(value) {
// Here you can customise value - I have an Array which I join using <br>
value.sort();
value = value.join("<br/>");
return value;
}
}
}
});
然后您在 Table HTML 中所要做的就是在列标题
上设置 data-type
<table id="myTable">
<thead>
<tr>
<th data-column-id="Id" data-visible="false" data-identifier="true" data-type="numeric">Id</th>
<th data-column-id="SelectedFeaturesNames" data-type="listDisplay">Features</th>
<!-- Note the data-type on the Features <th> is listDisplay -->
</tr>
</thead>
<tbody></tbody>
</table>
Did it work using that method?
是的@Dawood Awan!它对我有用
PHP:
<td>
<?php
$test = ['b', 'a', 'c'];
echo json_encode($test);
?>
</td>
JS:
to: function(value) {
value = JSON.parse(value); //convert received json to js array.
value.sort();
value = value.join("<br/>");
return value;
}
有一种方法可以使用 jquery-bootgrid 使单元格内的 <br>
可见吗?因为 <br>
的渲染不可见。
我的理解是你想在你的数据中添加一个换行符,像这样,
在功能列中,我传递了一个数组,它使用 <br>
为此您可以创建一个自定义转换器,
http://www.jquery-bootgrid.com/Documentation#converters
您可以在初始化 BootGrid 时创建转换器 Table
var dt = $('#myTable').bootgrid({
//.......... Other Options
converters: {
listDisplay: {
from: function(value) {
return value;
},
to: function(value) {
// Here you can customise value - I have an Array which I join using <br>
value.sort();
value = value.join("<br/>");
return value;
}
}
}
});
然后您在 Table HTML 中所要做的就是在列标题
上设置 data-type <table id="myTable">
<thead>
<tr>
<th data-column-id="Id" data-visible="false" data-identifier="true" data-type="numeric">Id</th>
<th data-column-id="SelectedFeaturesNames" data-type="listDisplay">Features</th>
<!-- Note the data-type on the Features <th> is listDisplay -->
</tr>
</thead>
<tbody></tbody>
</table>
Did it work using that method?
是的@Dawood Awan!它对我有用
PHP:
<td>
<?php
$test = ['b', 'a', 'c'];
echo json_encode($test);
?>
</td>
JS:
to: function(value) {
value = JSON.parse(value); //convert received json to js array.
value.sort();
value = value.join("<br/>");
return value;
}