简体   繁体   English

如何获取Bootstrap表数据并删除行

[英]How to get Bootstrap table data and delete the row

This is a part of my ejs file. 这是我的ejs文件的一部分。 assume that, there is bootstrap table as below. 假设存在如下引导表。

What I want to do is that, if I press a button, my del() function will be executed for selected row deletion. 我想做的是,如果我按一个按钮,我的del()函数将被执行以删除选定的行。 But it's not working. 但这不起作用。 my function even don't get the 'row.data' 我的功能甚至没有得到“ row.data”

How do I get the row.data and delete a row based on the row.data? 如何获取row.data并基于row.data删除行?

 $('#table').bootstrapTable({
               columns: [{
                      field: 'no',
                      title: 'No',
                      align: 'center',
                      valign: 'middle',
                      sortable: true
                  }, {
                      field: 'seq',
                      title: 'rank',
                      align: 'center',
                      valign: 'middle',
                      sortable: true
                  }, {field: 'title',
                      title: 'name',
                      align: 'center',
                      valign: 'middle',
                      sortable: true }, [
                  ]data: [{
                      id: 1,
                      no: 1,
                      seq:1,
                      title: 'Test 1',

                  },{
                      id: 2,
                      no: 2,
                      seq: 2,
                      title: 'Test 2',
                     }]
                    });

function del(){

   var $table = $('table');
   var ids = $.map($table.bootstrapTable('getSelections'), function (row) {
        console.log("checked");
        return row.data;
   });
   console.log("Ids : " + ids);

  $('#table').bootstrapTable('remove', {
       index : 1
    });
  }

You have missed the # sign in del function. 您已经错过了del功能中的#号登录。 It should be- 它应该是-

var $table = $('#table');

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

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