您好,欢迎来到爱够旅游网。
搜索
您的当前位置:首页bootstrap-table如何给行内添加操作函数及功能按键

bootstrap-table如何给行内添加操作函数及功能按键

来源:爱够旅游网
$('#table').bootstrapTable('destroy'); 
$('#table').bootstrapTable({
// data:reet.data,
url:'../data/yonghuguanli.json',
// uniqueId: "SOBID",
striped:true,
pagination:true,
clickToSelect:true,
height:580,
   columns: [{
    checkbox:true, 
   },{
       field: 'id',       
      sortable:true,
       title: '组织编码',
       sortable: true,
   },{
       field: 'name',
       title: '组织名称',
       sortable: true,
   },{
       field: 'lexing',
       title: '账套编号',
       sortable: true
   },{
       field: 'zt',
       title: '账套名称',
       sortable: true
   }, {
       field: 'operate',
       title: '操作',
       align: 'center',
       events: "operateEvents",
       formatter: operateFormatter
        }],

});


2:表格中增加按钮
operateFormatter(value, row, index):这三个参数是bootsharp-table默认的

function operateFormatter(value, row, index) {
            return [
                '<button type="button" class="RoleOfA btn btn-default  btn-sm" style="margin-right:15px;">A权限</button>',
                '<button type="button" class="RoleOfB btn btn-default  btn-sm" style="margin-right:15px;">B权限</button>',
                '<button type="button" class="RoleOfC btn btn-default  btn-sm" style="margin-right:15px;">C权限</button>',
                '<button type="button" class="RoleOfD btn btn-default  btn-sm" style="margin-right:15px;">绑定D</button>',
                '<button type="button" class="RoleOfEdit btn btn-default  btn-sm" style="margin-right:15px;">编辑</button>'
            ].join('');

        }


3:注册按钮的点击事件
每个按钮对应哪个点击事件,是用Class里面的属性标识的,如上步骤2(比如:RoleOfA)

window.operateEvents = {
            'click .RoleOfA': function (e, value, row, index) {
                alert("A");            
         },
            'click .RoleOfB': function (e, value, row, index) {
                alert("B");            
         },
          'click .RoleOfC': function (e, value, row, index) {
                alert("C");            
         },
        'click .RoleOfEdit': function (e, value, row, index) {
        alert("D"); 
           }
        };

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- igbc.cn 版权所有 湘ICP备2023023988号-5

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务