bootstrapTable,fastadmin里如何添加自定义的按钮,又如何在自定义按钮里追加参数,因为需要用到,所以发出来让需要用到的朋友可以自取-亲测可用

整个table里面的代码
  // 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: '编号'},
{field: 'no', title: __('No'), operate: 'LIKE'},
{field: 'name', title: __('Name'), operate: 'LIKE'},
{field: 'price', title: __('Money'), operate: 'LIKE'},
{field: 'category.name', title: __('Category.name'), operate: 'LIKE'},
{field: 'model', title: __('Model'), operate: 'LIKE'},
{field: 'brand', title: __('Brand'), operate: 'LIKE'},
{field: 'status', title: __('Status'), searchList: {"idle":__('Idle'),"scrap":__('Scrap'),"use":__('Use'),"repair":__('Repair'),"sell":__('Sell'),"make":__('Make')}, formatter: Table.api.formatter.status},
{field: 'invoice', title: __('Invoice'), searchList: {"special":__('Special'),"ordinary":__('Ordinary'),"receipt":__('Receipt')}, formatter: Table.api.formatter.normal},
{field: 'create_id', title: __('Create_id')},
{field: 'assetswarehouse.name', title: __('Assetswarehouse.name'), operate: 'LIKE'},
{field: 'admin.nickname', title: __('Admin.username'), operate: 'LIKE'},
{field: 'id', title: __('功能区'), table: table, buttons: [
{name: 'detail', text: '子资产', title: '子资产', icon: 'fa fa-list', classname: 'btn btn-xs btn-primary btn-dialog', url: 'assets/high/index?fid={id}', callback:function(data){}},
{name: 'detail', text: '使用', title: 'Ajax标题', icon: 'fa fa-flash', classname: 'btn btn-xs btn-success btn-ajax', url: 'assets/high/view?id={id}', success:function(data, ret){}, error:function(){}},
], operate:false, formatter: Table.api.formatter.buttons},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
buttons: [
{name: 'detail', title: '转移资产', icon: 'fa fa-arrows-h', classname: 'btn btn-xs btn-primary btn-dialog', url: 'assets/high/yidong', callback:function(data){}},
]
}
]
]
});

具体实现用的是下面这段代码,icon是图标样式,btn-ajax说明是ajax请求,而另外一个则是打开一个窗口进行操作,后面如何追加get参数启蒙博客有标注,也很容易看懂,后面的success和error是成功和失败后的回调

{field: 'id', title: __('功能区'), table: table, buttons: [
{name: 'detail', text: '子资产', title: '子资产', icon: 'fa fa-list', classname: 'btn btn-xs btn-primary btn-dialog', url: 'assets/high/index?fid={id}', callback:function(data){}},
{name: 'detail', text: '使用', title: 'Ajax标题', icon: 'fa fa-flash', classname: 'btn btn-xs btn-success btn-ajax', url: 'assets/high/view?id={id}', success:function(data, ret){}, error:function(){}},
], operate:false, formatter: Table.api.formatter.buttons},

点赞(0) 打赏

Comment list 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部