col.sTitle.replace is not a function
col.sTitle.replace is not a function
prasadnadendla
Posts: 2Questions: 1Answers: 0
I am using title of type function instead of string. It throws the above error during sorting.
Using latest version of data-tables.net package along with the licensed version of editor
Answers
Happy to take a look at a test case showing the issue so I can help resolve it or patch DataTables if needed.
Allan
@allan Thank you for your prompt response. After examining the source, it appears that there is no logic to perform type checking before treating it as a string replacement.
I put together this little example, and yes I see the issue. However,
columns.title
does document that it should be given as a string. If you are passing in a number, add.toString()
after the number or just+ ''
and it should work as expected.edit Sorry - you are using a function. Yes, that isn't supported at all for the title. You'll need to execute the function at initialisation time to get the value (a string).
Allan
Thanks @allan. Certainly, I understand now. Apologies for the confusion, as I initially thought it supported function types. Could you please guide me on how to add a custom element to the header without it being affected by the sorting click?
Put your
span
, or whatever tag you want into the header and then stop the event from bubbling. Here is a little example.Allan