C#和Jquery Datatables服务器端处理问题

时间:2018-12-12 13:06:32

标签: javascript c# jquery datatables jquery-datatables-editor

我要将数据从存储过程返回到jquery Datatable表,但是由于返回的数据量很大,我正在努力实现服务器端处理,并且仅加载请求的数据(ei 10、20、50、100 )

这是我的JavaScript代码

 $(document).ready(function () {
        $.ajax({
            "dataType": "application/json",
            "type": "GET",
            "url": "http://localhost:54888/api/order",
            "success": function (dataStr) {
                console.log(dataStr.responseText);
                // laod Data to DataTable Jquery
                var resp =  jQuery.parseJSON(dataStr.responseText ? dataStr.responseText : dataStr);
                $('#example').DataTable({
                    data: resp["rows"],
                    columns: resp["aoColumns"],
                    scrollX: true,
                    autoWidth: true,
                    bScrollCollapse: true,
                   // paging: true,
                   // retrieve: true,
                    "jQueryUI": true,
                   // serverSide: true,
                    processing:true

                });
            },
            "error": function (dataStr) {
                //console.log(dataStr);
                var resp = jQuery.parseJSON(dataStr.responseText ? dataStr.responseText : dataStr);
                $('#example').DataTable({

                    data: resp["rows"],
                    columns: resp["aoColumns"],
                    scrollX: true,
                    autoWidth: true,
                    bScrollCollapse: true,
                    //paging: true,
                    //retrieve: true,
                    "jQueryUI": true,
                   // serverSide: true,
                    processing: true
                });

            }
        })
    });

我有一种很棒的方法可以将数据过滤为仅用户正在查看的内容?而不是加载所有50万条记录。

非常感谢

0 个答案:

没有答案