No data in SearchPane

No data in SearchPane

sunny1407sunny1407 Posts: 3Questions: 2Answers: 0

Hey everyone, am new here and I have this problem plzz anyone help me am so stuck in this..

am building this project in Laravel 7, I used datatables and used ajax to load data into the table, bellow are all the related pages,

HTML

 <table class="table table-bordered table-striped table-vcenter js-dataTable-full" id="table_id">
                    <thead>
                    <tr>
                        <th>Campus Code</th>
                        <th>Name</th>
                        <th>Phone</th>
                        <th>Address</th>
                        <th>Action</th>
                    </tr>
                    </thead>
                    <tbody></tbody>
                </table>

SCRIPT

function loadtbl() {
                $('#table_id').DataTable(
                    {
                        dom: 'Bfrtip',
                        searchPanes:{
                            cascadePanes: true
                        },

                        buttons: [
                            'colvis', 'copy', 'csv', 'excel', 'pdf', 'print', 'searchPanes'
                        ],
                        fixedHeader: true,
                        responsive: true,
                        searchPanes: true,
                        serverSide: true,
                        processing: true,
                        ajax: '{!! route('campuses.index') !!}',
                        columns: [
                            {data: 'ccode', name: 'ccode'},
                            {data: 'name', name: 'name'},
                            {data: 'phone', name: 'phone'},
                            {data: 'address', name: 'address'},
                            {data: 'action', name: 'action', orderable: false, searchable: false},
                        ],
                        columnDefs:[
                            {
                                searchPanes:{
                                    show: true,
                                },
                                targets: [0,1,2,3],
                            }

                        ]
                    }
                );
                $('#table_id').DataTable().searchPanes.rebuildPane();
            }
            loadtbl();

Laravel Controller

public function index(Request $request)
    {
        if ($request->ajax()) {
            $data = Campus::orderBy('id','desc');
            return datatables()::of($data)
                ->addIndexColumn()
                ->addColumn('action', function($row){
                    $action = '<a id="show" data-toggle="modal" data-id='.$row->id.'><button type="button" class="btn btn-rounded btn-outline-success">Show</button></a>
<a id="edit" data-id='.$row->id.'><button type="button" class="btn btn-rounded btn-outline-warning">Edit</button> </a>
<meta name="csrf-token" content="{{ csrf_token() }}">
<a id="delete" data-id='.$row->id.'><button type="button" class="btn btn-rounded btn-outline-danger">Delete</button></a>';

                    return $action;
                })
                ->rawColumns(['action'])
                ->make(true);

        }

        return view('campuses.index');

    }

Now everything is working fine, all the pagination and search and everything is fine, The only problem is tht searchpanes dont Work, Plzzzz anyone tell me wht should I do about it, I think I have made some dumb mistake over here.

Here is a video link
https://drive.google.com/file/d/1aMOQJx2GX69i7K-8a05X4muVleuIA5HW/view

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Since you are using server-side processing, you need to return SearchPanes data in the format described here.

    Allan

  • sunny1407sunny1407 Posts: 3Questions: 2Answers: 0

    Hey Allan,
    Thanks for your reply, bt am still stuck and cant understand how can I do this in my project (and I did google and tried alot to make it work but its still same)

    Can u plzzz spare some minutes and tell me how shd I make it work in the above given example, or if u can kindly provide me a link to a working example.

    Thanks

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    There is a working example of SearchPanes with server-side processing using the Editor PHP libraries available here.

    See also this blog post on the topic.

    Allan

This discussion has been closed.