gpt4 book ai didi

javascript - 删除一行 Bootstrap Table

转载 作者:行者123 更新时间:2023-11-28 15:17:55 29 4
gpt4 key购买 nike

打扰一下,我现在正在使用这个Bootstrap table .我不知道如何删除表格中的一行,我见过one similar example在文档中,但我真的不明白这是什么意思。特别是我不知道 {field: 'id', values: ids} 是什么意思。我想要实现的用户体验是在我想要删除的任何行中单击按钮,然后该行将被删除。

最佳答案

获取定义的 Bootstrap 表作为变量。

let table = $('#table');

使用移除按钮检测点击事件

$(document).on('click', '.removeRowButton', function() {

在 Bootstrap 表中,行中的元素具有数据索引。

下一行获取点击行索引

    let rowid = $(this).closest('tr').data('index');

内置删除行的函数

    table.bootstrapTable('remove', {
field: '$index',
values: [rowid]
});


let table = $('#table');
$(document).on('click', '.removeRowButton', function() {
let rowid = $(this).closest('tr').data('index');
table.bootstrapTable('remove', {
field: '$index',
values: [rowid]
});
});

关于javascript - 删除一行 Bootstrap Table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40376767/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com