I want to display a (large amount) of data stored in an array from the fomrat:
records = ["First", "Second", "Third", "...", "last"];
I am using the following javascript to display the data.
<script>
$(document).ready(function() {
$('#example').DataTable({
data: records,
deferRender: true,
ordering: false,
columns: [
{ title: "Title" }
]
});
} );
But when i want to show the results each character is displayed as one row.
If is switch the representation of the records
to records = [["First"], ["Second"], ["Third"], ["..."], ["last"]];
it is all fine. But I don't want to change the data structure to the last format.
Is there a possibility to render the data without a nested array?
Is it an option to transform the array inplace?:
$('#example').DataTable({
data: records.map(e => [e]),
deferRender: true,
ordering: false,
columns: [
{ title: "Title" }
]
});
The original array would remain unmodified.
Is there a possibility to render the data without a nested array?
No. Datatable renders data per row by array index.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.