Bootstrap-based jQuery editable table plugin Bootstable

Add-ons
2026-07-26 04:34 3 次浏览 • 0 次下载 3.3KB
Bootstrap-based jQuery editable table plugin Bootstable

Last updated: 2019-11-28 10:25:46

Bootstable

A JavaScript library that makes HTML tables editable using Bootstrap

Bootstable

"Bootstable" is a JavaScript library (plugin) that allows static HTML tables to be converted into editable tables. Editable tables include multiple buttons for performing editing operations.

Editing options include:

  • Specified table cells can be edited.

  • Table rows can be deleted.

  • New table rows can be added.

Usage

Include the jquery and bootstable.js files in the page.

1
2
<script src="path/to/jquery.min.js"></script>
<script src="path/to/bootstable.js"></script>

HTML Structure

Use the table template provided by Bootstrap as the HTML structure for the table.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<div class="table-responsive">
<table class="table table-bordered table-striped" id="mytable">
<thead>
<tr>
<td>Name</td>
<td>Age</td>
<td>email</td>
</tr>
</thead>
<tbody>
<tr>
<td>Zhang San</td>
<td>25</td>
<td>zs@163.com</td>
</tr>
<tr>
<td>Li Si</td>
<td>23</td>
<td>lisi@qq.com</td>
</tr>
<tr>
<td>Wang Wu</td>
<td>24</td>
<td>ww@126.com</td>
</tr>
</tbody>
</table>
</div>

If you want to add table rows, you also need to add a button.

1
<button class="btn btn-info" id="add"><i class="fa fa-plus"></i> Add a new table row</button>

Initialize the Plugin

After the page DOM elements have finished loading, initialize this jQuery table editing plugin using the SetEditable() method.

1
$('#mytable').SetEditable();

Note: You must add an ID to the table. Each call to SetEditable() can initialize only one table. If you have multiple tables, call SetEditable() separately for each one.

Configuration Parameters

The available configuration parameters for this jQuery table editing plugin are:

1
2
3
4
5
6
7
8
$('#mytable').SetEditable({
columnsEd: null, //Index to editable columns. If null all td editables. Ex.: "1,2,3,4,5"
$addButton: null, //Jquery object of "Add" button
onEdit: function() {}, //Called after edition
onBeforeDelete: function() {}, //Called before deletion
onDelete: function() {}, //Called after deletion
onAdd: function() {} //Called when added a new row
});
  • columnsEd: The indexes of the table columns to be edited.

  • $addButton: The jQuery object representing the button used to add table rows.

  • onEdit: Callback function triggered when editing a table.

  • onBeforeDelete: Callback function triggered before deleting a table row.

  • onDelete: Callback function triggered after deleting a table row.

  • onAdd: Callback function triggered before adding a new table row.

For example:

1
2
3
4
5
6
7
$('#mytable').SetEditable({
columnsEd: "0,1", // Edit the first and second columns
$addButton: $('#but_add'),
onEdit: function() {
//console.log("Edit table");
}
});
星河码客

发现和分享优质开源项目,传承互联网精神,为开发者服务。

关于本站

联系我们

微信/广告合作:ITcloub (备注星河码客)

免责声明:本站资源版权归原作者所有,仅供学习与交流。如有侵权,请通过「关于我们 - 侵权投诉」联系删除。

Powered by Nuxt · Deployed on Cloudflare