Cannot use stateLoadCallback to load visibility settings of columns

Cannot use stateLoadCallback to load visibility settings of columns

mappomappo Posts: 2Questions: 1Answers: 0

Hi, I've been trying to use stateSaveCallback to save the state (including visibility settings of columns) to database and then stateLoadCallback to load the previous state. I was able to load the state for column re-ordering, pagination, search terms, and entry number, but I wasn't able to load the state of visibility of columns.
There was no "responsive" setting.

The record in the database shows clearly that the column visibility settings were saved correctly, so the only problem is why stateLoadCallback didn't load the visibility settings.

The followings are the code snippets, could you please help me with this? Thanks a lot!

var dt = $('#example').dataTable({
                    stateSave : true,
                    "stateDuration": 60 * 60 * 24*365*100,
                    "scrollY" : "800px",
                    "scrollCollapse" : true,
                    "processing" : true,
                    "serverSide" : true,
                    "ajax" : "loaditems.php",
                    "columns" : [{
                        "className" : "details-control",
                        "data" : null,
                        "defaultContent" : ""
                    }, {
                        "data" : "Name"
                    }, {
                        "data" : "User"
                    }, {
                        "data" : "Date"
                    }, {
                        "data" : "Checked"
                    }, {
                        "data" : "Location"
                    }, {
                        "data" : "Note"
                    }],
                    "order" : [[1, 'asc']],
                    "dom" : 'R<"tips">lf<"clear">Crtip',
                    "stateSaveCallback" : function(settings, data) {
                        $.ajax({
                            "url" : "statesave.php",
                            "data" : data,
                            "dataType" : "json",
                            "type" : "POST",
                            success : function(data) {  
                            }
                        });
                    },

                    "stateLoadCallback" : function(settings) {
                        var o;
                        $.ajax({
                            "url" : "stateload.php",
                            "async" : false,
                            "dataType" : "json",
                            "success" : function(json) {
                                o = json;
                            }
                        });
                        return o;
                    }
                });

$("div.tips").html('<b>Choose to &nbsp;</b>');
    

Answers

  • mappomappo Posts: 2Questions: 1Answers: 0

    I forgot to mention that I use DataTables 1.10.6

This discussion has been closed.