sData .charAt Error
sData .charAt Error
I accept all suggestions, but this is mostly directed to allan, which I hope allan you can help me out.
I've read about the errors surrounding this type detection\sorting plugin, for per instance 'currency' detection.
You said in a thread (I've lost track) that it happens when DataTables it's trying to "work" on something that it's not a string.
You also said that you've came across this a few times and you tried to fix it, well, what happens here is, I was implementing a custom currency type detection with success, then I have two fields that came from the DB (two integers), which I don't treat at all, so they are handled such as:
"field" : 134,
And I get -> sData.charAt is not a function
If I for instance (in PHP) $field = "". $field;
I get this in the aaData
"field" : "134",
And problem solved, but I have lots of tables I want to implement my custom currency, and I don't want to this "weird" trick to make my int's- string's, so DataTables doesn't trip out on me.
I've read about the errors surrounding this type detection\sorting plugin, for per instance 'currency' detection.
You said in a thread (I've lost track) that it happens when DataTables it's trying to "work" on something that it's not a string.
You also said that you've came across this a few times and you tried to fix it, well, what happens here is, I was implementing a custom currency type detection with success, then I have two fields that came from the DB (two integers), which I don't treat at all, so they are handled such as:
"field" : 134,
And I get -> sData.charAt is not a function
If I for instance (in PHP) $field = "". $field;
I get this in the aaData
"field" : "134",
And problem solved, but I have lots of tables I want to implement my custom currency, and I don't want to this "weird" trick to make my int's- string's, so DataTables doesn't trip out on me.
This discussion has been closed.
Replies
Allan
Also allan, I can't run debugger on the page, obviously, if I let the error happen. But want me to run it without the error, so you can look at the sAjaxSource JSON and see if why if I let it come as an int, it crashes?
Thanks.
Thanks,
Allan
I might be looking at the "Orthogonal data" post you made, this was hard to find, but it seems it may even be a better option, to use a currency example you have there for better filtering, sorting, then the type detection thing, since I added the EUR manually.
I'd just add something like:
[code]
if ( typeof sData !== 'string' ) {
return null;
}
[/code]
at the top of that plug-in function.
Allan
Mainly saying you should consider adding that to your function example, since it's suppose to work on strings (currency) and it doesn't have that verification.
I for one, thought it was the core, didn't look at it correctly.
Sorry, and thank you. !
Allan