selectpage添加默认选项
//如果发送的来源是 Selectpage,则转发到 Selectpage
if ($this->request->request('keyField')) {$result=$this->selectpage();//获取JSON数据$content=json_decode($result->getContent(),true);//解构["list"=>$list,"total"=>$total]=$content;//添加初始默认值array_unshift($list, ['id'=>0,"classify_name"=>'无']);//total +1 return json(['list'=>$list,'total'=>$total+1]);
}
自定义按钮
{field: 'operate', title: __('Operate'), table: table,buttons: [{name: "classify",text: "会场管理",//按钮名称//classname 按钮类型有 btn-dialog、btn-ajax、btn-addtabs、btn-clickclassname: 'btn btn-xs btn-success btn-addtabs',icon: 'fa fa-sitemap',// url: 'hotel/classify?city_id={id}',url:function(row){return 'hotel/classify?city_code='+row['city_code']+'&city_customized=1';},visible:function(row){console.log(row);return (row.status && row.hot) ? true : false;}}],events: Table.api.events.operate, formatter: Table.api.formatter.operate}
设置dailog弹框大小
表格外dialog弹框大小,设置在Table.api.init上面
$(".btn-add").data("area",["90%","90%"]);// 初始化表格参数配置Table.api.init({
表格内dialog btn弹框大小,设置在表格绑定事件上面
table.on("post-body.bs.table",function(){$(".btn-editone").data("area",["90%","90%"])
});
隐藏表格列中的删除按钮
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function(value,row,index){
var that = $.extend({}, this);var table = $(that.table).clone(true);if (row.id <4){$(table).data("operate-del", null);}that.table = table;return Table.api.formatter.operate.call(that, value, row, index);}}
通用搜索 查询关联表中字段
public function hotel(){return $this->belongsTo('Hotel','hotel_id','id')->setEagerlyType(0);
}
根据权限 列formatter显示不同api
使用场景举例说明 超级管理员权限拥有审核权限 而普通管理只需知道审核状态,这里主要使用的是Tabel.api.formatter.status和Table.api.formatter.toggle,简单的使用不同的形态,大家都知道,问题是需要根据条件不同动态显示,废话不多说,看源码
{field: 'status', title: '审核', searchList: {"0":'已审核',"1":"未审核"}, formatter: function(value,row,index){if(row.status==1){return Table.api.formatter.toggle.call(this,value,row,index);}else{return Table.api.formatter.status.call(this,value,row,index);}}}
侧边栏 增加数字提醒
使用场景,新订单总量显示在侧边栏menu上提示
//左侧菜单
//修改admin/controller/Index.php index
list($menulist, $navlist, $fixedmenu, $referermenu) = $this->auth->getSidebar(['dashboard' => 'hot','addon' => ['new', 'red', 'badge'],'auth/rule' => __('Menu'),'reservation?status=99'=>(new \app\common\model\Reservation)->where("status",99)->count(),'quotation'=>(new \app\common\model\Quotation)->where("status",7)->count(),'apply'=>(new \app\common\model\Apply)->where("status",1)->count(),], $this->view->site['fixedpage']);