How to store the state info only for particular actions like colreorder,column visibility and sort
How to store the state info only for particular actions like colreorder,column visibility and sort
Madhavi Bhimisetty
Posts: 11Questions: 1Answers: 0
I am able to save the state of user using stateSaveCallback . But when I click on row and going to the next page also its performing stateSaveCallback function. I want control that.
Pls help.
Replies
Use
stateSaveParams
to delete the items you don't want from the state object.Allan
I just click on a row but its calling stateSaveCallback function 2 time I am not understanding.
please help me.
"stateSaveCallback": function (settings, data) {
for (const column in data.columns) { //I do not want to save the search criteria to the database. It could make the string too long
delete data.columns[column].search;
}
delete data.select;
var tableListJSON = {};
var tableListJSON = JSON.stringify(data);
},
stateSaveParams: function (settings, data) {
delete data.search;
},
Looks like you are using the Select extension. When you click a row and its selected or deselected then stateSave will update / save the current state. Same with other actions on the table. This is why you see it called many times. As Allan said if you don't want to save the sate of certain things like search then use
stateSaveParams
to remove those options.Kevin
I have added data.select in statesaveparams aas mentioned below
stateSaveParams: function (settings, data) {
delete data.search;
delete data.select;
},
In this data the select method was not there i think.
But still its calling save state function many times.
And its not going to backed as selected row also.And I don't want to save also.
If I remove select: true , then I am not able to perform CRUD operations like create and edit.
Please help me.
I built a test case to show that
delete data.select;
works. You are right it doesn't work. The test case shows the object is deleted but when the state is loaded the select object is there. Not sure if @allan considers this a bug but it seems the StateSave library saves the select state afterstateSaveParams
.http://live.datatables.net/qoluroce/1/edit
You can remove the StateSave information using
stateLoadParams
. The example shows this.Kevin