<script type="text/javascript">
        <!-- 方法定义 -->
        function addFunctionToTable(value, row, index) {
           return [
           '<button id="preview" type="button" class="btn btn-default">预览</button>'
           ].join('');
         }
        <!-- 操作事件 -->
        window.operateEvents = {
            'click #preview': function (e, value, row, index) {
               alert(row.naspath);
             }
           };
        <!-- 关键代码 -->
         $('#table').bootstrapTable({
         。。。
         columns: [{
            checkbox: true
        }, {
            field: 'id',
            title: '编号',
        }, {
            field: 'name',
            title: '名称',
        }, {
            field: 'operate',
            title: '操作',
            events: operateEvents,//给按钮注册事件
            formatter: addFunctionToTable//表格中增加按钮
        }]
    </script>

  

posted on 2024-05-01 17:39  le.li  阅读(46)  评论(0编辑  收藏  举报