using ajax reload , removes pagination and information from bottom grid

using ajax reload , removes pagination and information from bottom grid

lalitsingh82lalitsingh82 Posts: 10Questions: 4Answers: 0
edited April 2018 in Free community support

Hi ,
I am implementing reload of data table on button click, i came to know from your site that using ajax only it is possible. on button click of refresh , when i am using ajax.reload or ajax.url.load, the pagination goes away , why this is happening.

$(document).ready(function () {

        $("#InitiatedCases").DataTable({

            "ajax": {
                "url": '@Url.Content("~/InitiatedCases/ReloadData")',
                "data": function (data, callback, settings){
                        callback(JSON.parse( localStorage.getItem('dataTablesData'))); 
                        }
            },
            dom: 'frtip',
            select: 'single',
            "lengthChange": false,
            "pageLength": 20,
            "order": [[0, "desc"]],
            "pagingType": "full_numbers",
            stateSave: true,
            stateSaveCallback: function (settings, data) {
                localStorage.setItem('DataTables_' + settings.sInstance, JSON.stringify(data))
            },
            stateLoadCallback: function (settings) {
                return JSON.parse(localStorage.getItem('DataTables_' + settings.sInstance))
            }

        });

button click

  $('#Refresh').on('click', function () {

     var loadtable = $('#InitiatedCases').DataTable();
     debugger;
            $.getJSON('@Url.Content("~/InitiatedCases/ReloadData")', function (data) {

                loadtable.ajax.reload();
            })
            .fail(function (jqXHR, textStatus, errorThrown) {

                    });

            //console.log("button click:" + table.id);
           //table.ajax.reload(null,false);
            //loadtable.ajax.url('@Url.Content("~/InitiatedCases/ReloadData/")').load();
        });

getting error, please see attachment

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Don't use $.getJSON in this case. You've already configured DataTables with ajax to tell it where to get Ajax data, so just use ajax.reload().

    If that isn't working for you, I'm happy to take a look at a test page showing the issue so I can help debug it.

    Allan

This discussion has been closed.