dcat-admin
dcat-admin copied to clipboard
使用分页 select 时, 无默认列表选项, 只能通过搜索获取列表
- Laravel Version: 8.83.3
- PHP Version: 8.0.9
- Dcat Admin Version: 2.2.0-beta
Description:
在没有搜索前应该如下代码展示 10 条默认数据, 然而现在只能通过搜索获取到数据
Form
$form->select('category_id')
->options(fn() => Model::take(10)->pluck('name', 'id'))
->ajax('api/categories/select');
Api
public function select()
{
$q = request('q');
return Model::where('name', 'like', "%$q%")->paginate(null, ['id', 'name as text']);
}
Steps To Reproduce:
搜索前
搜索后
参考文档测试同样得结果
遇到了同样的问题,请问题主解决了吗
遇到了同样的问题,请问题主解决了吗
丢个 demo 出来看看
我这想显示拼接后的结果 Form
$form->select('softwares_id')->options(function ($id) {
$software = Software::find($id);
if ($software) {
return [$software->id => $software->name.' '.$software->version];
}
})
->ajax('api/softwares');
Api
{
$q = $request->get('q');
return Software::where('name', 'like', "%$q%")->paginate(null, ['id', 'name as text']);
}
@laradocs
遇到了同样的问题,请问题主解决了吗
没有解决
你们谁解决了可以分享一下😂
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
不改变源码得情况下,在ajax()后面增加
->config('minimumInputLength',0)
执行无参数请求获取对应列表