bootstraptable通过数据属性或javascript以表格格式显示数据
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了 bootstraptable通过数据属性或javascript以表格格式显示数据,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2732字,纯文字阅读大概需要4分钟。
内容图文
bootstraptable通过数据属性或javascript以表格格式显示数据
通过数据属性(把数据写死)
<table data-toggle="table">
<thead>
<tr>
<th>Item ID</th>
<th>Item Name</th>
<th>Item Price</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Item 1</td>
<td>$1</td>
</tr>
<tr>
<td>2</td>
<td>Item 2</td>
<td>$2</td>
</tr>
</tbody>
</table>
我们还可以通过data-url="data1.json"
在普通表上设置来使用远程URL数据。
<table
data-toggle="table"
data-url="data1.json">
<thead>
<tr>
<th data-field="id">Item ID</th>
<th data-field="name">Item Name</th>
<th data-field="price">Item Price</th>
</tr>
</thead>
</table>
我们还可以添加pagination
,search
和sorting
表格,如下表所示。
<table
data-toggle="table"
data-url="data1.json"
data-pagination="true"
data-search="true">
<thead>
<tr>
<th data-sortable="true" data-field="id">Item ID</th>
<th data-field="name">Item Name</th>
<th data-field="price">Item Price</th>
</tr>
</thead>
</table>
通过JavaScript
通过JavaScript调用带有id表的bootstrap Table。
<table id="table">
</table>
$('#table').bootstrapTable({
columns: [{
field: 'id',
title: 'Item ID'
}, {
field: 'name',
title: 'Item Name'
}, {
field: 'price',
title: 'Item Price'
}],
data: [{
id: 1,
name: 'Item 1',
price: '$1'
}, {
id: 2,
name: 'Item 2',
price: '$2'
}]
})
我们还可以通过设置来使用远程URL数据url: 'data1.json'
。
$('#table').bootstrapTable({
url: 'data1.json',
columns: [{
field: 'id',
title: 'Item ID'
}, {
field: 'name',
title: 'Item Name'
}, {
field: 'price',
title: 'Item Price'
}]
})
还可以添加pagination
,search
和sorting
表格,如下表所示。
$('#table').bootstrapTable({
url: 'data1.json',
pagination: true,
search: true,
columns: [{
field: 'id',
title: 'Item ID'
}, {
field: 'name',
title: 'Item Name'
}, {
field: 'price',
title: 'Item Price'
}]
})
//项目中的代码如下
/*
有思路:将下面渲染table的语句写在websocket函数内,只要触发该函数,就进行刷新渲染,实现实时刷新。
*/
$("#UploadTable").bootstrapTable('destroy').bootstrapTable({
// 策略列表table
columns: [{
field: 'StgID',
title: '策略ID'
}, {
field: 'uStgName',
title: '策略名称'
}, {
field: 'uUpTime',
title: '指定服务器'
}, {
field: 'uServer',
title: '运行状态',
}, {
field: 'uoption',
title: '操作',
formatter: function (value, row, index) {
return "<span onclick=\"modify('" + value + "')\" class='btn btn-success btn-xs btn-flat btn_operation' data-toggle='modal' data-target='#modal_backtest_detail'> <i class='fa fa-pencil'></i>启动</span> " +
" <span onclick=\"del_('" + value + "')\" type='button' class='btn btn-danger btn-xs btn-flat btn_operation'> <i class='fa fa-pencil'></i>停止</span>" +
" <span onclick=\"del_('" + value + "')\" type='button' class='btn btn-danger btn-xs btn-flat btn_operation'> <i class='fa fa-pencil'></i>人工录入</span>";
}
},
{
field: 'fkong',
title: '风控',
}],
data: [{
StgID: 1,
uStgName: "test1",
uUpTime: "服务器1",
uServer: "运行中",
uoption: 1,
fkong: "fk1"
},]
})
内容总结
以上是互联网集市为您收集整理的 bootstraptable通过数据属性或javascript以表格格式显示数据全部内容,希望文章能够帮你解决 bootstraptable通过数据属性或javascript以表格格式显示数据所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。