我想在bootstrap-table中添加一个指向列的链接。该怎么做呢?
发布于 2015-06-05 02:00:38
在HTML表中:
<th data-field="snum" data-formatter="LinkFormatter">Computer</th>在你的javascript中:
function LinkFormatter(value, row, index) {
return "<a href='"+row.url+"'>"+value+"</a>";
}发布于 2015-01-07 20:17:07
我使用‘formatter’对象找到了这个机制。下面是一个格式化程序的例子。
function identifierFormatter(value, row, index) {
return [
'<a class="like" href="javascript:void(0)" title="Like">',
value,
'</a>'].join('');
}基本上,要使用它,必须将其作为HTML数据属性添加到表头。
<th data-field="identifier" data-align="right" data-sortable="true" data-formatter="identifierFormatter">Identifier</th>发布于 2017-09-14 03:08:10
html
<table id="table_exemple" data-toggle="table" data-pagination="true" >
<thead>
<tr>
<th data-field="id">Id</th>
<th data-field="name">Nome</th>
<th data-field="action" data-formatter="ActionFormatter">Details</th>
</tr>
</thead>
<tbody></tbody>
</table>javascript
var bootstrap_table = $('#table_exemple');
function AddRow(obj){
bootstrap_table.bootstrapTable('insertRow', {
index: 0,
row: {
id: obj.id,
name: obj.name,
action: obj.id
}
});
}
function ActionFormatter(value) {
return '<a href="javascript:void(0)" onclick="Details('+ value +')">Details</a>';
}
function Details(id){
...
}https://stackoverflow.com/questions/27819208
复制相似问题