php
/**
* @description: 类型列表
* @return {*}
*/
public function get_type_list()
{
$params=$this->request->param();
if ($this->request->isAjax()) {
$where['status']=1;
$list=$this->model->where($where)->select();
$list=collection($list)->toArray();
$result=$result = array("total" => count($list), "rows" => $list);
if(isset($params['tableselect']) && $params['tableselect']==1){
return json($list);
}else{
return json($result);
}
}
}
js
var web_type_list=[];
$.ajax({
url:'web/type/get_type_list',
type:'post',
data:{tableselect:1},
async: false,
success:function(res){
web_type_list=res;
}
})
fastadmin table field=web_type_id 改为下拉
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'weigh',
fixedColumns: true,
fixedRightNumber: 1,
searchFormVisible:true,
columns: [
[
{checkbox: true},
{field: 'name', title: __('Name'), operate: 'LIKE'},
{field: 'type.name', title: __('Type.name'), operate: false},
{field: 'weigh', title: __('Weigh'), operate: false},
{field: 'title', title: __('Title'), operate: false},
{field: 'web_type_id', title: __('Web_type_id'),visible:false,searchList: web_type_list , data:'data-live-search="true"'},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 设置成可以查询下拉内容 data:'data-live-search="true"' 添加class
$('[name="web_type_id"]').addClass('selectpicker');