简体   繁体   English

删除一行 Bootstrap Table

[英]Delete a row of Bootstrap Table

Excuse me, now I am using this Bootstrap table .对不起,现在我正在使用这个Bootstrap 表 I don't know how to remove a row in the table, I have seen one similar example in the documentation, but I don't really understand what it means.我不知道如何删除表中的一行,我在文档中看到了一个类似的例子,但我真的不明白它是什么意思。 Especially I don't know what {field: 'id', values: ids} means.特别是我不知道{field: 'id', values: ids}是什么意思。 The user experience I want to achieve is click button in any row that I want to remove, then that row will be removed.我想要实现的用户体验是在我想要删除的任何行中单击按钮,然后该行将被删除。

Get defined bootstrap table as variable.获取定义的引导表作为变量。

let table = $('#table');

Detect click event with remove button使用删除按钮检测点击事件

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

In bootstrap-table elements in rows have data-index.在行中的引导表元素中,有数据索引。

Next row getting clicked row index下一行被点击行索引

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

Built in function for removing rows用于删除行的内置函数

    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]
    });
});
 $(document).on('click', 'button.removebutton', function () { // <-- changes
     $(this).closest('tr').remove();
     return false;
 });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM