pagination fix: with stateSaveCallback/stateLoadCallback make sure numeric values are not strings
pagination fix: with stateSaveCallback/stateLoadCallback make sure numeric values are not strings
I noticed that my pagination was broken after I started to use stateSaveCallback/stateLoadCallback to save the state of my tables in my database. I found out it was due to the numeric values in the JSON array being saved as strings (mainly the start and length indexes). I am using PHP to handle the AJAX request, and my remedy to this was to make sure to use the JSON_NUMERIC_CHECK param with the json_encode() function.
Example:
public function table_state_save()
{
$state_json = json_encode($_POST, JSON_NUMERIC_CHECK);
// code to save to database here
}
Just wanted to share this in case others were finding their pagination is/was breaking after implementing server-side state saving.