bootstrap-table.js如何删除actionevent中的行

时间:2015-05-15 02:38:11

标签: bootstrap-table

如何更改此小提琴中的“提醒”点击事件,以删除点击该图标的行?我尝试了几种方法都没有效果。我想删除/删除行,而不是发布警报。先感谢您。

以下是Fiddle

        function actionFormatter(value, row, index) {
        return [
    '<a class="like" href="javascript:void(0)" title="Like">',
    '<i class="glyphicon glyphicon-heart"></i>',
    '</a>',
    '<a class="edit ml10" href="javascript:void(0)" title="Edit">',
    '<i class="glyphicon glyphicon-edit"></i>',
    '</a>',
    '<a class="remove ml10" href="javascript:void(0)" title="Remove">',
    '<i class="glyphicon glyphicon-remove"></i>',
    '</a>'
       ].join('');
          }

   window.actionEvents = {
     'click .like': function (e, value, row, index) {
    alert('You click like icon, row: ' + JSON.stringify(row));
    console.log(value, row, index);
},
'click .edit': function (e, value, row, index) {
    alert('You click edit icon, row: ' + JSON.stringify(row));
    console.log(value, row, index);
},
'click .remove': function (e, value, row, index) {
    alert('You click remove icon, row: ' + JSON.stringify(row));
    console.log(value, row, index);
     }
      };

1 个答案:

答案 0 :(得分:0)

补充:var $ table = $(&#39;#table&#39;)

这对点击功能:   &#39;点击。删除&#39;:功能(e,值,行,索引){                    $ table.bootstrapTable(&#39; remove&#39;,{                     字段:&#39; id&#39;,                     值:[row.id]                 });

现在它有效。

      var   $table = $('#table')

 function actionFormatter(value, row, index) {
    return [
'<a class="like" href="javascript:void(0)" title="Like">',
'<i class="glyphicon glyphicon-heart"></i>',
'</a>',
'<a class="edit ml10" href="javascript:void(0)" title="Edit">',
'<i class="glyphicon glyphicon-edit"></i>',
'</a>',
'<a class="remove ml10" href="javascript:void(0)" title="Remove">',
'<i class="glyphicon glyphicon-remove"></i>',
'</a>'
   ].join('');
      }

   window.actionEvents = {
     'click .like': function (e, value, row, index) {
    alert('You click like icon, row: ' + JSON.stringify(row));
    console.log(value, row, index);
},
'click .edit': function (e, value, row, index) {
    alert('You click edit icon, row: ' + JSON.stringify(row));
    console.log(value, row, index);
},
    'click .remove': function (e, value, row, index) {
               $table.bootstrapTable('remove', {
                field: 'id',
                values: [row.id]
            });
    }
};