【问题标题】:How to add "Column Search" with infyom laravel-generator datatable如何使用 infyom laravel-generator 数据表添加“列搜索”
【发布时间】:2021-09-16 11:22:42
【问题描述】:

是否可以使用 infyom laravel-generator yajra 数据表添加“列搜索”。

我将 tables_searchable_default 从 false 更改为 true

形成这个文档https://www.infyom.com/open-source/laravelgenerator/docs/8.0/configuration#options

但它并没有改变任何东西......

这样有解决办法吗?

提前致谢。

【问题讨论】:

  • 发布您的 yajra 数据表代码
  • 嗨 @sta 不知道你想要哪个文件,我使用这个 cde "php artisan infyom:scaffold $Model --fromTable --tableName=$table --datatables=true"并且 infyom 在许多不同的文件中创建所有 conf ...

标签: laravel yajra-datatable infyom


【解决方案1】:

我在 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') @endsection

{{-- $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 $(文档).ready(函数() { // 设置 - 为每个页脚单元格添加一个文本输入 $("#dataTableBuilder tfoot th").each( function () { var 标题 = $(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( function () { var that = this; $( "input", this.footer() ).on( "keyup change clear", function () { if ( that.search() !== this.value ) { 那 .search(this.value) 。画(); } }); }); } }); } ); 5 • 供应商/yajra/laravel-datatables-html/src/Html/Builder.php 公共函数 generateScripts() { $parameters = $this->generateJson(); $parameters=substr($parameters,0,strlen($parameters)-1); # 删除最后一个 } 以添加参数 返回新的 HtmlString( sprintf($this->template(), $this->getTableAttribute('id'), $parameters) ); }

【讨论】:

    猜你喜欢
    • 2017-04-18
    • 2017-04-28
    • 2018-06-03
    • 2020-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-12
    • 2021-01-16
    相关资源
    最近更新 更多