I have JSON data that's rendered via a DataTable and in one of the columns the text shows up as capitalized, and I want it to be like This where only the first letter is uppercase.
As per other posts on SO, it was recommended that .toUppercase
and .slice
be used. Based on what I have I feel that my code should be working, but for some reason it isn't. Since I'm working with DataTables I have had to go over a few hurdles to get results, so I'm wondering if DT is at the root of the problem as well.
JS snippet:
$(document).ready(function() {
$('#matters-table').DataTable({
columns: [
{ data: "0" },
{ data: "1" },
{ data: "Status" }, // is in all caps when rendered
{ data: "3" }
],
columnDefs: [
{"targets":2,"render": function(data) {
return data[0].toUpperCase() + data.slice(1);
}}
],
data: mattsText,
... // --------------- irrelevant info.
Any thoughts on this one?