问题描述
是否可以使用 infyom laravel-generator yajra 数据表添加“列搜索”。
我将 tables_searchable_default 从 false 更改为 true
形成此文档 https://www.infyom.com/open-source/laravelgenerator/docs/8.0/configuration#options
但它并没有改变任何东西......
有解决方案吗?
提前致谢。
解决方法
我在 Infyom Gihthub 上的回答
https://github.com/InfyOmLabs/laravel-generator/issues/972
我是如何做到的(在 yajra/datables-html/builler 中稍作修改 - 参见步骤 5)
0-https://datatables.net/examples/api/multi_filter.html
◦ reference example
1-php artisan infyom.publish:templates
2-resources/infyom/infyom-generator-templates/scaffold/views/datatable_body.stub
datatable_body.stub @section('third_party_stylesheets') @include('layouts.datatables_css') @结束部分
{{-- $dataTable->table(['width' => '100%','class' => 'table table-striped table-bordered']) --}} {!! $dataTable->table(['width' => '100%','class' => 'table table-striped table-bordered'],true) !!} {{-- drawFooter --}}
3 config/datatables-html.php
'数据表::脚本','脚本' => '布局/脚本',];
4 个资源/视图/布局/script.blade.php
$(document).ready(function() {
// 设置 - 向每个页脚单元格添加文本输入
$("#dataTableBuilder tfoot th").each( function () {
var title = $(this).text();
$(this).html("");
});
});
$(function(){window.{{ config('datatables-html.namespace','LaravelDataTables') }}=window.{{ config('datatables-html.namespace','LaravelDataTables') }}||{ };window.{{ config('datatables-html.namespace','LaravelDataTables') }}["%1$s"]=$("#%1$s").DataTable(%2$s,initComplete: 函数 () {
// 应用搜索
this.api().columns().every(函数(){
var that = this;
$( "input",this.footer() ).on( "keyup change clear",function () {
if ( that.search() !== this.value ) {
那
.search( this.value )
。画();
}
});
});
}
}); }
);
5 • vendor/yajra/laravel-datatables-html/src/Html/Builder.php
公共函数 generateScripts()
{
$parameters = $this->generateJson();
$parameters=substr($parameters,strlen($parameters)-1); # 删除最后一个 } 以添加参数
返回新的 HtmlString(
sprintf($this->template(),$this->getTableAttribute('id'),$parameters)
);
}