Column Data being displayed with only first character of data.
Column Data being displayed with only first character of data.
I have a datatable which is being populated on a button click. I am adding rows to the table on ajax success call using table.rows.add(data)
, where 'data' is the data returned from the server. Sample data returned from the server is of type List<String>, when printed on the console looks like ["Nothing", "Something"]. My datatable is intended to have two columns, Description | Select.
Here 'Description' is the data that has been returned from the server using ajax call and Select is a button link which calls an action when clicked.
The code for my datatable is as below :
$("#datatable").DataTable({
"deferRender": true,
"iDisplayLength": 25,
"columnDefs":[
{
"targets": -1,
"data":null,
"defaultContent": "<span class='glyphicon glyphicon-info-sign'></span>",
"orderable" : false,
"searchable": false,
"width": "20%"
}
],
"order": [[0, 'asc']]
});
The problem here is that the data in the first column displays only the first character as shown in the attached screenshot. Am I missing some configuration for the datatable which is the cause of this problem ?
Answers
Found a workaround for this problem by iterating through the json object and adding values for each cell in the row like below :
Note that I had two display columns in the Datatable, hence I have added value for first cell and '' (no value) for the select column.
Hm.. typically, thats a sign that a string is being treated as an array..
EG:
If you could replicate this on http://live.datatables.net/ for me to see, then we could find the "real" solution for this.