How to load using string array?
How to load using string array?
rusumat
Posts: 10Questions: 5Answers: 1
Hi, I living a problem when data load using string array.
My codes;
var agendaSplit = "Row 1[&]Row 2[&]Row 3[&]Row 4[&]Row 5".split('[&]');
$('#AgendaListTable').DataTable({
"info": true,
dom: 'Bfrtip',
buttons: ['excel', 'pdf', 'print'],
data: agendaSplit,
language: {
"url": "//cdn.datatables.net/plug-ins/1.10.15/i18n/English.json",
buttons: {
}
}
});
Result;
I don't want to this.
I want this but I can't;
Can you help me?
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Results in this:
["Row 1", "Row 2", "Row 3", "Row 4", "Row 5"]
But what you really need is for each row to be in its own array. Something more like this:
[["Row 1"], ["Row 2"], ["Row 3"], ["Row 4"], ["Row 5"]]
Kevin
@kthorngren thank you for the answer. I solved in following way;
Finally, yes, we solved my problem but I wonder is there another way? I wonder is there a faster solution?
For example 'for' instead of what else can be used?
You could use
Array.prototype.map
and a fat arrow function:Or old style:
Allan