This time, I’m loading both configuration and data for a datatable from the server. It is in the form of json. When I load the file a second time, it breaks.
I figured out already that it has to do something with the format property for one of the column, but I can’t figure out how to fix it. Also it happens to only occur when the object passed to parse is loaded from a json string.
In the following Snippet, the table parses either the static JavaScript object defined at the top of the code or the json code located in a hidden textarea, depending on which of the line you uncomment.
I’m desperately trying to figure out what happened, but I can’t. I tried to compare both objects in the console but I can’t find a difference between the two. I hope someone can spot the mistake.
I investigated a little further and found out the following:
parse modifies the object passed to it, replacing the string "numberFormat" with the respecting function. When you parse the same object again, the format property already contains a function and it works.
If you try to parse a different object with a string as its format property again, the table tries to treat the string as a function, causing a “string is not a function” error.
I can’t figure out why it doesn’t resolve the string to a function the second time.
After reloading columns the grid repaints self without normalizing the columns configuration.
As temporary fix you can use onServerConfig event, from which you can force structure update. Starting from the next build the same functionality will work without extra event handlers.