1.生成的字段用图片格式展示,加 formatter: Table.api.formatter.images
{field: 'the_third_party_images', title: __('The_third_party_images'), formatter: Table.api.formatter.images},
2.生成按钮键,点击执行ajax
{
field: 'buttons',
width: "240px",
title: __('按钮组'),
table: table,
events: Table.api.events.operate,
buttons: [
{
name: 'ajax',
text: __('更新此分类下的商品'),
title: __('更新此分类下的商品'),
classname: 'btn btn-warning btn-magic btn-ajax', //warning 按钮颜色控制
icon: '',
url: 'thethirdparty/Saler/updateCatGoods/cat_id/{the_third_party_cat_id}',
confirm: '确认同步',
success: function (data, ret) {
Layer.alert(ret.msg);
//如果需要阻止成功提示,则必须使用return false;
//return false;
},
error: function (data, ret) {
Layer.alert(ret.msg);
return false;
},
visible: function (row) {
//返回true时按钮显示,返回false隐藏
if(row.is_separate == 1){
return true;
}else{
return false;
}
}
}
],
formatter: Table.api.formatter.buttons
}
3.index.html 列表上面的自定义按钮要执行ajax
//index.html文件
<a class="btn btn-primary {:$auth->check('thethirdparty/thethirdpartycat/add')?'':'hide'}" data-params="" id="updateCategory" href="javascript:;" data-multiple="true"><i class="fa fa-play"></i> 一键同步Saler分类</a>
//对应的JS文件
$("#updateCategory").click(function () {
Layer.confirm(
'是否从同步第三方分类?',
{icon: 3, title: __('Warning'), shadeClose: true},
function (index) {
console.log(index);
Layer.close(index);
if(index == 1){
Fast.api.ajax({
url:'thethirdparty/Saler/synchCat/type/saler'
}, function(data, ret){
console.log(data);
});
}
}
);
});
(在这个之前)
// 为表格绑定事件
Table.api.bindevent(table);
网友评论