load jsp on ajax success in datatable is loosing pagination

load jsp on ajax success in datatable is loosing pagination

paruldataparuldata Posts: 2Questions: 1Answers: 0
edited February 2021 in Free community support

var table = $('#tbleDataGrid').DataTable({
//destroy:true,
orderCellsTop: true,
//fixedHeader: false,
stateSave: true,
"stateSaveCallback": function (settings, data) {
$.ajax( {
"url" : "/tableFilterDetail?action="+eventStatus+"&periodRange="+periodRange +"&lastRecordOflastPage="+lastRecordOfPagination +"&pagingAction="+pagingAction,
"data": data,
// "dataType": "json",
"type": "GET",
"success": function (response) {
$('#pageID').html(response);}

                            } );
                          }

After ajax success,I am loosing all the datatable properties.
Kindly support.Thanks in advance

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    With out a test case showing the issue ([which is required for support, per the forum rules) it is impossible to say what is going wrong. However, my guess is that with $('#pageID').html(response);} you are overwriting the HTML for the DataTable. But as I say, without a test case, I can’t be sure. Certainly, writing into the HTML for a state save callback seems like an odd thing to do.

    Allan

  • paruldataparuldata Posts: 2Questions: 1Answers: 0

    yes,that was the culprit ..
    $('#pageID').html(response);
    have added below line and pagination is working properly but unable to load save state..
    $('#hometbleDataGrid').DataTable();
    I can't return json as my data is huge in modelandview object and this is spring mvc project...
    https://jsfiddle.net/4oLrsykx/
    Thanks!!

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

    Thanks for the test case, unfortunately it doesn't run. We need to be able to see the problem you want help with to be able to progress this,

    Colin

This discussion has been closed.