why search is not working on my datatable

why search is not working on my datatable

ridwandwiseptianridwandwiseptian Posts: 1Questions: 1Answers: 0
edited July 2021 in DataTables
   <div class="row">
    <div class="col-12">
        <div class="card mg-b-20">
            <div class="card-body">
                <div class="main-content-label mg-b-5">
                    Data Dosen
                </div>
                <br />
                <div class="table-responsive">
                    <table class="table table-bordered mg-b-0 text-md-nowrap" id="dt-Dosen">
                        <thead>
                            <tr>
                                <th>No</th>
                                <th>@Html.DisplayNameFor(model => model.NIDN)</th>
                                <th>@Html.DisplayNameFor(model => model.KD_PSA)</th>
                                <th>@Html.DisplayNameFor(model => model.NAMA)</th>
                                <th>@Html.DisplayNameFor(model => model.GELAR_DEPAN)</th>
                            </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>




 <script type="text/javascript">
            $(function () {
                var t = $('#dt-Dosen').DataTable({
                    "columnDefs": [{

                    }],
                    "columns": [
                        {
                            "data": null, "sortable": true,
                            render: function (data, type, row, meta) {
                                return meta.row + meta.settings._iDisplayStart + 1;
                            }
                        },
                        {
                            "data": "nidn" 
                        },
                        {
                            "data": "kD_PSA"
                        },
                        {
                            "data": "nama"
                        },
                        {
                            "data": "gelaR_DEPAN"
                        },
                    ],
                    "language": {
                        "lengthMenu": "_MENU_ Data per Halaman",
                        "zeroRecords": "Nothing found - sorry",
                        "search": "Pencarian",
                        "info": "Jumlah Halaman _PAGE_ - _PAGES_",
                        "infoEmpty": "No records available",
                        "infoFiltered": "(filtered from _MAX_ total records)"
                    },
                    "order": [[3, "asc"]],
                    "pagingType":"full_numbers",
                    "processing": true,
                    "serverSide": true,
                    "filter": true,
                    "searching": true,
                    "pageLength": 10,
                    "ajax": {
                        url: "@Url.Action("GetMasterDosen")",
                        method: "POST",
                    },
                });

                t.on('order.dt search.dt', function () {
                    t.column(0, { search: 'applied', order: 'applied' }).nodes().each(function (cell, i) {
                        cell.innerHTML = i + 1;
                    });
                }).draw();
            });
        </script>

Answers

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    You are using server side processing ("serverSide": true,) which means the server script is responsible for search, sorting and paging. The protocol is documented here. Here is a basic server side example. Here is the example ssp script used by the exmaples.

    Are you using a datatables provided server side script? You will need to look at your server script to determine why its not searching.

    Kevin

Sign In or Register to comment.