早睡早起,方能养生
Sleep early rise early, way to keep healthy

Fastadmin 高级搜索 输入框 动态请求数据

super
2023-01-31 19:03
views 3854

1)将operate修改为如图所示

 

{field: 'project_title', title: __('Project_title'), operate: 'LIKE %...%'},

 

 

2)在js中加上这么一段

 

 

table.on("post-common-search.bs.table", function (event, table) {
	var form = $("form", table.$commonsearch);
	$("input[name='project_title']", form).addClass("selectpage").data("source", "project/selectAll").data("primaryKey", "title").data("field", "title").data("orderBy", "id asc");
	// 解析:$("input[name='原输入框字段名']", form).addClass("selectpage").data("source", "数据请求地址").data("primaryKey", "传输字段【点击搜索按钮,会传此字段的值给后端】").data("field", "展示字段【select下拉框展示的字段】").data("orderBy", "id asc");
	// ... 可一次修改多个字段
	Form.events.cxselect(form);
	Form.events.selectpage(form);
});

 

3)PHP Controller代码

 

public function selectAll()
{
    if ($this->request->request('keyField')) {
        return $this->selectpage();
    }
}

 

4)效果

 



分享
0 条讨论
top