data is truncated at the comma
data is truncated at the comma
hank scorpio
Posts: 7Questions: 1Answers: 0
Hi--
Whenever my cell's data contains a comma, the text after it is truncated. Is there way around this?
I'm getting my data from an Ajax post, and creating the table like this:
var rt=$("#resultsTable").DataTable({
data:s
});
What I see, for example, is this:
Some Company
Instead of this:
Some Company, Inc.
Any help is appreciated. Thank you!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Oh, using version DataTables 1.10.13.
How are you building
s
?Kevin
Also, could you use the debugger so we can see the configuration.
Thanks,
Allan
Have you looked at the raw data in s? If you have a string "Company, Inc", DataTables is not going to change that so I would start looking at your data.
Are your columns wide enough?
@kthorngren -- s is returned from an Ajax post. I have a PHP script running a query, then returning the data. The process is a bit messy because the names and amount of columns are dynamic. I send a query to my script by AJAX, then get a string back. I use JavaScript to build a table and add it to my DOM. Like this:
@bindrid -- Looking at the data logged in my console, it looks fine there. I'm getting data back in this format:
column data,column data,column data~column data,column data,column data~column data,column data,column data~||column name,column name,column name
I really need to build the table dynamically because my client wants to choose which columns will display. It's messy, but the whole thing works almost perfectly, except this comma problem.
@allan -- I haven't used the debugger before. That's a good idea. Let me try this and see what happens.
Thank you!
I'm unclear what your data structure is that is returned from ajax but I think the problem is with the
xx=d[i].split(",");
in line 6. Looks like this might result in two array elements for the column with "Some Company, Inc.". If this is the case then it seems Datatables will only use the first array element.I may be wrong. I would recommend using
console.log
to see how your loops are building your data.Kevin
Well, crap. I see the problem now. I'm splitting my string on a comma. I need to find a different delimiter.
Thanks everyone and sorry for wasting your time.
@kthorngren ... thank you. I spotted that after posting my code and I really appreciate your response.
Changing that comma to a caret did the trick.