Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82258

How to implement local pagination functionality with data from Ajax?

$
0
0

Hi, I would like to be able to get all records from SQL and use "local" pagination (without fetching new records from SQL whenever I select another page (next/previous)).

ServerSide and Pagination works fine when I fetch the data using standard "SELECT". The problem is, I could not use pagination for the data that I obtained via SQL Stored Procedure with ServerSide On.

I understand that I could separate the process (call the Ajax and then draw the table afterwards). However, it would require me to restructure the JS which would be very complex.

Is it possible to achieve this? If yes, how?

Please let me know if you need more information. Thanks in Advance,

Relevant Code:

var table = $('#table').DataTable({
        "searching": false,
        "scrollX": true,
        "scrollY": true,
        "searchDelay": 400,
        "createdRow": function (row, data, dataindex) {
            
        },
        "order": [[0, 'asc']],
        "processing": true,
        "serverSide": true,
        "columns": [
            //columns...
        ],
        "ajax": {
            "url": "Default.aspx/loadStoredProcedure",
            "type": "POST",
            "contentType": "application/json; charset=utf-8",
            "dataType": "text",
            "dataSrc": "data",
            "data": function (d) {
                return JSON.stringify({ parameters: d });
            },
            "dataFilter": function (res) {
                let parsed = JSON.parse(res);
                return parsed.d;
            },
            "error": function (data) {
            }
        },
        "drawCallback": function (settings) {
            //some processing
        },
        "initComplete": function (settings, data) {
            //some processing
        }
    });

Viewing all articles
Browse latest Browse all 82258

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>