to set the data from the second column (skip first)
to set the data from the second column (skip first)
Hi! Is it possible to get a table to insert the data only in certain columns? For example, I would want that in the first column are keys to redatirovaniya, and insert data in the rest of the Ajax request. If one uses such a structure, all well:
var table = $('#example').DataTable( {
"ajax": "data/arrays.txt",
"columnDefs": [ {
"targets": -1,
"data": null,
"defaultContent": "<button>Click!</button>"
} ]
} );
But I need to insert the edit button in the first column
var table = $('#example').DataTable( {
"ajax": "data/arrays.txt",
"columnDefs": [ {
"targets": 0,
"data": null,
"defaultContent": "<button>Click!</button>"
} ]
} );
in this case, the data for the first column are replaced by button
I can not to use the following structure,
"columns": [
{ "data": "name" },
{ "data": "name" },
]
as the data comes in the form of an array of strings
{
[
"Tiger Nixon",
"System Architect",
"Edinburgh",
"5421",
"2011/04/25",
"$320,800"
],
[
"Garrett Winters",
"Accountant",
"Tokyo",
"8422",
"2011/07/25",
"$170,750"
],
}
Is there a setting that allows to set the data from the second column?
Answers
Hi , I have exactly same requirement. I am not able to find solution anywhere. Did you find any solution or workaround? Kindly help
Its easier if you are using objects rather than arrays of the data source since you would just assign the property name to the column you want, but basically it works the same for arrays - use
columns.data
to get the data from the element in the array you want for that columns:etc.
DataTables will automatically use the column index to read from the array, but you don't always need to do that.
Allan