Datatables not working search after AJAX

Datatables not working search after AJAX

omerfekremomerfekrem Posts: 1Questions: 1Answers: 0
edited August 2020 in Free community support

Hello I'm adding enough data tables with ajax. It is being added but the search section does not work and there are fifteen more pages at the bottom but I have a single page yield.

<script>
    function Doldur() {
        var url = "@Url.Action("Veriler", "ListData")";
        $('#packages').DataTable({
            "bProcessing": true,
            "serverSide": true,
            "ajax": {
                url: url, // json datasource
                type: "post",  // type of method  , by default would be get
            },
            "aoColumns": [
                { "data": "order_no", "bSearchable": true},
                            { "data": "order_item_no"},
                            { "data": "first_name"},
                            { "data": "last_name"},
                            { "data": "title" },
                            { "data": "sub_district"},
                            { "data": "district"},
                            { "data": "city"},
                            { "data": "adress"},
                            { "data": "first_phone" },
                            { "data": "second_phone" },
                            { "data": "third_phone" },
                            { "data": "email" },
                            { "data": "delivery_date" },
                            { "data": "delivery_time_slot" },
                            { "data": "delivery_day_slot" },
                            { "data": "desi" },
                            { "data": "total_sales_gross_price" },
                            { "data": "item_count" },
                            { "data": "price_type" },
                            { "data": "order_message" },
                            { "data": "username" },
                            { "data": "kontrol_edildi" },
            ],

            responsive: true,
            bDestroy: true,
            "language": {
                "info": "Sayfa _PAGE_ / _PAGES_",
                "paginate": {
                    "first": "ilk",
                    "last": "Son",
                    "next": "Sonraki",
                    "previous": "Önceki"
                },
                "emptyTable": "Sonuç Bulunamadı",
                "search": "Sonuc İçi Arama",
                "infoEmpty": "Gösterilen Kayıt 0 / 0 ",
                "lengthMenu": "Gösterilen_MENU_ Adet"
            },

            scrollCollapse: true,
            paging: true,
            "bSort": false,
            "lengthMenu": [10],
            "lengthChange": false
        });
    }
    Doldur();
</script>
public JsonResult Veriler()
        {
            var veriler = db.Packages.ToList();
            return Json(new { data = veriler}, JsonRequestBehavior.AllowGet);

        }

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    You've enabled serverSide, so the server script is expected to perform all paging and searching operations. If you're expecting to have less than 5k rows, you can disable serverSide as the client-side performance will likely be adequate,

    Colin

This discussion has been closed.