server side saved state sometimes reset to default

server side saved state sometimes reset to default

valenpovalenpo Posts: 12Questions: 0Answers: 0

Using 1.10.15b datatables (no way to upgrade now) for a day it work perfect, save/load state. After while, mostly next date state reset to default. Checked server side database, it contains proper values.

Any direction for investigation?

"stateSave": true,
                "colReorder": true,
                "stateSaveParams": function (settings, data) {
                    var colNames = [];
                    for (var colIndex = 0; colIndex < settings.aoColumns.length; colIndex++) {
                        var colName = $(settings.aoColumns[colIndex].nTh).attr("name");
                        colNames.push(colName);
                        data.columns[colIndex].sWidth = settings.aoColumns[colIndex].sWidth;
                        data.columns[colIndex].sWidthOrig = settings.aoColumns[colIndex].sWidth;
                    }

                    for (var colIndex = 0; colIndex < data.columns.length; colIndex++) {
                        data.columns[colIndex].name = colNames[colIndex];
                    }
                    data.instance = settings.sInstance;
                    data.state = "save";
                    data.ColReorder = undefined;
                },
                <% if (!clipped) {%>
                "stateSaveCallback": function (settings, data) {
                    try {
                        var columnsInfo = JSON.stringify(data);
                        $.ajax({
                            type: "POST",
                            url: "search.do?jsm=getSettings",
                            data: {instance: form.instance, settings: columnsInfo},
                            async: false
                        });

                        if (isPageChecked(form)) {
                            $(form.form + ' .dataTables_scrollHeadInner th :checkbox').attr('checked', true);
                        } else $(form.form + ' .dataTables_scrollHeadInner th :checkbox').attr('checked', false);
                    } catch (e) {
                        console.error(e)
                    }
                },
                "stateLoadCallback": function (settings, callback) {
                    var data = null;
                    try {
                        $.ajax({
                            type: "GET",
                            url: "search.do?jsm=getSettings",
                            async: false,
                            success: function (json) {
                                json.state = "load";
                                data = json;
                                if (callback)
                                    callback(json)
                            }
                        });
                    } catch (e) {
                        console.error(e)
                    }

                    return data;
                },

Replies

  • colincolin Posts: 14,618Questions: 1Answers: 2,497

    It seems odd that it just stopped working. What did you do between it working and not working? Did you upgrade any of the components?

    To debug, you say the values are correct in the DB, you could also look at the values sent to DataTables as well - look at the network tab in the browser's dev tools,

    Colin

Sign In or Register to comment.