PHP laravel 列搜索无法有效地与 ->editcolumn getdatatable 一起工作

PHP laravel column search is not working efficiently with ->editcolumn getdatatable

搜索列的脚本:

<script>
    $.fn.dataTable.ext.errMode = 'none';
    var tableObj;

    $(document).ready(function(){
        // debugger;
        $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });

         tableObj = $('{{ $class_name }}').DataTable({

                searchable: true,
                processing: true,
                serverSide: true,
                 "aaSorting": [],
                cache: true,
                type: 'GET',
                ajax: '{{ $routeValue }}',
                @if(isset($table_columns))
                columns: {!!$setData!!}
                @endif
                initComplete: function () {
                    this.api().columns().every(function () {
                        var column = this;
                        var input = document.createElement("input");
                        $(input).appendTo($(column.header()))
                        .on('keyup', function () {

                            column.search($(this).val(), false, false, true).draw();
                        });

                    });
                }


        });

          $('.datatable').find('select.form-control').removeClass('form-control input-sm').addClass('full-width').attr('data-init-plugin','select2');        
    });
    // console.log("it is working");
  </script>

获取数据的控制器函数:

 $records = array();
   dd($record);
             $records = User::join('roles', 'users.role_id', '=', 'roles.id')

            ->select(['users.id','users.name', 'phone','users.default_bill_address','area','users.created_at','website','user_status','reason_inactive','is_online','login_enabled','role_id',

              'slug'])->orderBy('users.created_at', 'desc');

             if(!isset($_GET['order'])){
              $records = $records ->whereIn('users.id',$list_his)->orderBy('users.created_at', 'desc');
           }
        return Datatables::of($records)
       ->editColumn ('default_bill_address', function($records){
          if($records->default_bill_address)
          {
            $add = Address::where('id',$records->default_bill_address)->first();
            if($add)
                return $add->fullAddress();
            else
                return '-';
         }
         else
            return '-';
        })

截图:

screenshot related to panel where search column is present.

描述

我在不同的 table 中以相同的方式编辑了许多列,当我在特定列中搜索时 returns 什么都没有,因为相关文本不在查询中 table 而且我无法在搜索时加入这么多 table 来获得结果。

我得到的最简单的解决方案

In your script just cahnge a single line serverSide: true to serverSide: false,

<script>
    $.fn.dataTable.ext.errMode = 'none';
    var tableObj;

    $(document).ready(function(){
        // debugger;
        $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });

         tableObj = $('{{ $class_name }}').DataTable({

                searchable: true,
                processing: true,
                serverSide: false,
                 "aaSorting": [],
                cache: true,
                type: 'GET',
                ajax: '{{ $routeValue }}',
                @if(isset($table_columns))
                columns: {!!$setData!!}
                @endif
                initComplete: function () {
                    this.api().columns().every(function () {
                        var column = this;
                        var input = document.createElement("input");
                        $(input).appendTo($(column.header()))
                        .on('keyup', function () {

                            column.search($(this).val(), false, false, true).draw();
                        });

                    });
                }


        });

          $('.datatable').find('select.form-control').removeClass('form-control input-sm').addClass('full-width').attr('data-init-plugin','select2');        
    });
    // console.log("it is working");
  </script>

this will change the server side searching into client-side. search from the content not from the datatable. How silly i was mistaking