state save is not working with statesavecallback ?

state save is not working with statesavecallback ?

karamkaram Posts: 31Questions: 14Answers: 0

1.when I was using only statesave:true it is saving state in cookies and on refreshing, subpage maintain it.
2. but when I added statesavecallback it doesn't work and I am trying to save data of columns name in a string to save data in database.
3. but my question is why statesave:true is not working with other code .?

code is here ..........

$.fn.getColumnsShown = function(dTable)
{
vCols = "";

     $.each(dTable.fnSettings().aoColumns, function(c){
     if(dTable.fnSettings().aoColumns[c].bVisible == true){
     vCols = vCols + dTable.fnSettings().aoColumns[c].sName +"|";
     }
     });

     return vCols;
     }
    $(document).ready( function () {        
     var table;
     table= $('#example).DataTable( {

                "processing": true,
                "deferRender": true,
                //"searching": true,
                //"serverSide": true,                   
                 dom: 'BRlfrtip',
                 buttons: [
                            {  extend: 'colvis',
                                text: 'Change Layout',
                                collectionLayout: 'fixed three-column'
                            }                     
                         ],             

                 "ajax": {
                            "url": "/example.so",
                            "type": "GET"
                             },
                 stateSave: true,
                 "stateSaveParams": function (settings, data) {
                       data.columnStr =  $('#example).getColumnsShown(this);

                      }, 
                 "stateSaveCallback": function (settings, data) {
                        // Send an Ajax request to the server with the state object
                        $.ajax( {
                          "url": "/example2.so",
                          "data": data,
                          "dataType": "json",
                          "type": "POST",
                          "success": function () {}
                        } );
                                              }, 

Answers

  • karamkaram Posts: 31Questions: 14Answers: 0

    on the cmd I am getting the visible columns names and other settings as well but on UI its not maintaining state as going to he subpage and coming back reloads the page but not gives the user settings.

This discussion has been closed.