支持多表格实例操作
This commit is contained in:
@ -88,7 +88,7 @@
|
||||
/* 新增表格行 */
|
||||
function insertRow(){
|
||||
var randomId = 100 + ~~(Math.random() * 100)
|
||||
$.btTable.bootstrapTable('insertRow', {
|
||||
$("#" + table.options.id).bootstrapTable('insertRow', {
|
||||
index: 0, // 你想插入到哪,0表示第一行
|
||||
row: {
|
||||
userId: randomId,
|
||||
@ -108,7 +108,7 @@
|
||||
$.modal.alertWarning("请至少选择一条记录");
|
||||
return;
|
||||
}
|
||||
$.btTable.bootstrapTable('remove', {
|
||||
$("#" + table.options.id).bootstrapTable('remove', {
|
||||
field: 'userId',
|
||||
values: ids
|
||||
})
|
||||
@ -116,18 +116,18 @@
|
||||
|
||||
/* 删除行ID值为1的数据 */
|
||||
function removeRowByUniqueId(){
|
||||
$.btTable.bootstrapTable('removeByUniqueId', 1)
|
||||
$("#" + table.options.id).bootstrapTable('removeByUniqueId', 1)
|
||||
}
|
||||
|
||||
/* 删除所有表格行 */
|
||||
function removeRowAll(){
|
||||
$.btTable.bootstrapTable('removeAll')
|
||||
$("#" + table.options.id).bootstrapTable('removeAll')
|
||||
}
|
||||
|
||||
/* 修改表格行 */
|
||||
function updateRow(){
|
||||
var randomId = 100 + ~~(Math.random() * 100)
|
||||
$.btTable.bootstrapTable('updateRow', {
|
||||
$("#" + table.options.id).bootstrapTable('updateRow', {
|
||||
index: 0, // 你想修改哪行,0表示第一行
|
||||
row: {
|
||||
userId: randomId,
|
||||
@ -143,7 +143,7 @@
|
||||
/* 修改行ID值为1的数据 */
|
||||
function updateRowByUniqueId(){
|
||||
var randomId = 100 + ~~(Math.random() * 100)
|
||||
$.btTable.bootstrapTable('updateByUniqueId', {
|
||||
$("#" + table.options.id).bootstrapTable('updateByUniqueId', {
|
||||
id: 1,
|
||||
row: {
|
||||
userId: randomId,
|
||||
@ -158,19 +158,19 @@
|
||||
|
||||
/* 查询表格所有数据值 */
|
||||
function getData(){
|
||||
var data = $.btTable.bootstrapTable('getData');
|
||||
var data = $("#" + table.options.id).bootstrapTable('getData');
|
||||
alert(JSON.stringify(data))
|
||||
}
|
||||
|
||||
/* 查询行ID值为1的数据 */
|
||||
function getRowByUniqueId(){
|
||||
var data = $.btTable.bootstrapTable('getRowByUniqueId', 1);
|
||||
var data = $("#" + table.options.id).bootstrapTable('getRowByUniqueId', 1);
|
||||
alert(JSON.stringify(data))
|
||||
}
|
||||
|
||||
/* 查询表格选择行数据值 */
|
||||
function getSelections(){
|
||||
var data = $.btTable.bootstrapTable('getSelections');
|
||||
var data = $("#" + table.options.id).bootstrapTable('getSelections');
|
||||
alert(JSON.stringify(data))
|
||||
}
|
||||
</script>
|
||||
|
@ -114,13 +114,13 @@
|
||||
|
||||
/* 查询表格所有数据值 */
|
||||
function getData(){
|
||||
var data = $.btTable.bootstrapTable('getData');
|
||||
var data = $("#" + table.options.id).bootstrapTable('getData');
|
||||
alert(JSON.stringify(data))
|
||||
}
|
||||
|
||||
/* 查询表格选择行数据值 */
|
||||
function getSelections(){
|
||||
var data = $.btTable.bootstrapTable('getSelections');
|
||||
var data = $("#" + table.options.id).bootstrapTable('getSelections');
|
||||
alert(JSON.stringify(data))
|
||||
}
|
||||
</script>
|
||||
|
@ -22,13 +22,16 @@
|
||||
</form>
|
||||
</div>
|
||||
<div class="btn-group-sm" id="toolbar1" role="group">
|
||||
<a class="btn btn-success">
|
||||
<a class="btn btn-success" onclick="options1()">
|
||||
<i class="fa fa-search"></i> options
|
||||
</a>
|
||||
<a class="btn btn-success" onclick="$.operate.add()">
|
||||
<i class="fa fa-plus"></i> 新增
|
||||
</a>
|
||||
<a class="btn btn-primary">
|
||||
<a class="btn btn-primary single disabled" onclick="$.operate.edit()">
|
||||
<i class="fa fa-edit"></i> 修改
|
||||
</a>
|
||||
<a class="btn btn-danger">
|
||||
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
|
||||
<i class="fa fa-remove"></i> 删除
|
||||
</a>
|
||||
</div>
|
||||
@ -57,13 +60,16 @@
|
||||
</div>
|
||||
|
||||
<div class="btn-group-sm" id="toolbar2" role="group">
|
||||
<a class="btn btn-success">
|
||||
<a class="btn btn-success" onclick="options2()">
|
||||
<i class="fa fa-search"></i> options
|
||||
</a>
|
||||
<a class="btn btn-success" onclick="$.operate.add()">
|
||||
<i class="fa fa-plus"></i> 新增
|
||||
</a>
|
||||
<a class="btn btn-primary">
|
||||
<a class="btn btn-primary single disabled" onclick="$.operate.edit()">
|
||||
<i class="fa fa-edit"></i> 修改
|
||||
</a>
|
||||
<a class="btn btn-danger">
|
||||
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
|
||||
<i class="fa fa-remove"></i> 删除
|
||||
</a>
|
||||
</div>
|
||||
@ -74,7 +80,7 @@
|
||||
</div>
|
||||
<div th:include="include :: footer"></div>
|
||||
<script th:inline="javascript">
|
||||
var prefix = ctx + "demo/table";
|
||||
var prefix = ctx + "demo/operate";
|
||||
var datas = [[${@dict.getType('sys_normal_disable')}]];
|
||||
|
||||
$(function() {
|
||||
@ -82,10 +88,10 @@
|
||||
id: "bootstrap-table1",
|
||||
toolbar: "toolbar1",
|
||||
url: prefix + "/list",
|
||||
showSearch: false,
|
||||
showRefresh: false,
|
||||
showToggle: false,
|
||||
showColumns: false,
|
||||
createUrl: prefix + "/add",
|
||||
removeUrl: prefix + "/remove",
|
||||
updateUrl: prefix + "/edit/{id}",
|
||||
modalName: "用户",
|
||||
columns: [{
|
||||
checkbox: true
|
||||
},
|
||||
@ -126,8 +132,8 @@
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)"><i class="fa fa-remove"></i>删除</a>');
|
||||
actions.push('<a class="btn btn-success btn-xs" href="###" onclick="$.operate.edit(\'' + row.userId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs" href="###" onclick="$.operate.remove(\'' + row.userId + '\')"><i class="fa fa-remove"></i>删除</a>');
|
||||
return actions.join('');
|
||||
}
|
||||
}]
|
||||
@ -141,10 +147,10 @@
|
||||
id: "bootstrap-table2",
|
||||
toolbar: "toolbar2",
|
||||
url: prefix + "/list",
|
||||
showSearch: false,
|
||||
showRefresh: false,
|
||||
showToggle: false,
|
||||
showColumns: false,
|
||||
createUrl: prefix + "/add",
|
||||
removeUrl: prefix + "/remove",
|
||||
updateUrl: prefix + "/edit/{id}",
|
||||
modalName: "用户",
|
||||
columns: [{
|
||||
checkbox: true
|
||||
},
|
||||
@ -185,14 +191,32 @@
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)"><i class="fa fa-remove"></i>删除</a>');
|
||||
actions.push('<a class="btn btn-success btn-xs" href="###" onclick="$.operate.edit(\'' + row.userId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs" href="###" onclick="$.operate.remove(\'' + row.userId + '\')"><i class="fa fa-remove"></i>删除</a>');
|
||||
return actions.join('');
|
||||
}
|
||||
}]
|
||||
};
|
||||
$.table.init(options);
|
||||
});
|
||||
|
||||
function options1() {
|
||||
var temp = "";
|
||||
var obj = table.config['bootstrap-table1'];
|
||||
for (var i in obj) {
|
||||
temp += i + ":" + obj[i] + "<br/>";
|
||||
}
|
||||
$.modal.alert(temp);
|
||||
}
|
||||
|
||||
function options2() {
|
||||
var temp = "";
|
||||
var obj = table.config['bootstrap-table2'];
|
||||
for (var i in obj) {
|
||||
temp += i + ":" + obj[i] + "<br/>";
|
||||
}
|
||||
$.modal.alert(temp);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user