jquery-datatables-checkboxes savestate question
jquery-datatables-checkboxes savestate question
Hi,
I'm using https://github.com/gyrocode/jquery-datatables-checkboxes/
And trying to save the statesave
In console.log on page load, there is no checkbox selected
using stateSaveCallback or stateSaveParams
the result for the checkbox state is
checkboxes: (2) [empty, {…}]
checkboxes: Array(2)
1: {}
length: 2
__proto__: Array(0)
I guess the problem come from this [empty, {…}] instead of displayed this [{…}]
I'm sending the table state like this "tablestate": JSON.stringify(data)
because I'm saving the state into DB and only the checkbox statevalues are not saved the other Datatables are saved ok
I'm using Datatables 1.10.11 (cannot update to latest for now)
Any idea what is going wrong and recommendation to fix this.
Answers
Is this the same issue as you reported here?
No it is not related (previous question was related to info true or false)
Now this is different issue related to stateSaveCallback or stateSaveParams
as for some reasons the values are not saved
I'm getting
[empty, {…}]
instead of this[{…}]
I'm wondering if something is wrong with query-datatables-checkboxes and the state when use with stateSaveCallback or stateSaveParams
I'm sending Datatables state like this and it's working fine with all Datatables States (except with the query-datatables-checkboxes)
"tablestate": JSON.stringify(data)
Your best bet is to get in touch with Gyrocode, the original author of that library. Its third party and not written nor supported by ourselves I'm afraid.
Allan
Hi Allan,
Yes I understand, I already have contacted him.
https://github.com/gyrocode/jquery-datatables-checkboxes/issues/107
Now I know how to reproduce the problem...
Here is an example https://jsfiddle.net/lenamtl/a8jurbp1/
The problem seems to occured when using column 1 for the checkbox
The result in console is
stateLoaded
checkboxes: (2) [null, {…}]
stateSaveParams
checkboxes: (2) [empty, {…}]
and that should be [{…}]
I just take a chance that maybe another dev encounter the same issue and have a solution
Hi,
I need to figure out based on this result
stateLoaded
checkboxes: (2) [null, {…}]
stateSaveParams
checkboxes: (2) [empty, {…}]
is this normal to have a **null **and **empty **value ?
Does Datatables can manage it or not?
That will help me to investigate...
I never see any null or empty value in the state result with the plugins i'm using ..
Thanks
Datatables doesn't manage what or how the plugins save the state. Your example seems to work and loads the checkbox states appropriately. Is there a problem I'm not seeing? Does the
null
orempty
array position affect something in your code?If you want to investigate you can open the checkboxes plugin source code and find where its saving the state.
Kevin
The state of the checkboxes are not save at all but the rest of the tables state aretsaved correctly.
I'm sending the table state like this "tablestate": JSON.stringify(data)
Does the example you posted not work not work for you?
https://jsfiddle.net/lenamtl/a8jurbp1/
It works for me.
Sounds like the basic Datatables and Gyrocode checkboxes functionality works with stateSave. But when you send to the server something server side doesn't like the
null
in the array. According to jsonlint the JSON string generated with thenull
array element instateSaveCallback
is valid with this result:Sounds like maybe something on the server side isn't handling this correctly. Have you looked there to see what is happening there?
What is the JSON response from the server?
Kevin
After several tests I finally found the problem
I have made a new jsfiddle that reproduce the problem using basic localstorage saved in browser
https://jsfiddle.net/lenamtl/ujqx9Lhc/1/
It appear that the problem occurred when using checkboxes in combinaison with Yadcf Datatables plugins...
That's a third-party extension so it would be worth raising with the author.
Colin
Yes I know
I was investigating ...
I'm just trying to find out if someone have the same issue and maybe found a solution.