index.html
<div class="panel-heading"> {:build_heading(null,FALSE)} <ul class="nav nav-tabs"> <li class="active"><a href="#all" data-toggle="tab">{:__('All')}</a></li> {foreach name="typeList" item="vo"} <li><a href="#{$key}" data-toggle="tab">{$vo}</a></li> {/foreach} </ul>
</div>
controller
public function _initialize() { parent::_initialize(); $this->view->assign("typeList", $this->model->getTypeList()); }
model
public function getTypeList() { //状态对应的显示参数 return ['1' => __('进行中'), '2' => __('暂停中'),'3' => __('已结束')]; } ```
js(大多数文章看不到,这个也是最容易忽略的一块!)
$('.panel-heading a[data-toggle="tab"]').on('shown.bs.tab', function (e) { var field = 'type'; ///筛选的字段
var value = $(this).attr("href").replace('#', ''); var options = table.bootstrapTable('getOptions'); options.pageNumber = 1; var queryParams = options.queryParams; options.queryParams = function (params) { params = queryParams(params); var filter = params.filter ? JSON.parse(params.filter) : {}; if (value !== '' && value != 'all') { filter[field] = value; } else { delete filter[field]; } params.filter = JSON.stringify(filter); return params; }; table.bootstrapTable('refresh', {}); return false; });
标签:__,function,选项卡,自定义,filter,params,fastadmin,var,options From: https://www.cnblogs.com/lusanqian/p/16805970.html