0

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?

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Well that is indeed an option. I already read through the documentation and haven‘t found any other option.
0

Is there a possibility to render the data without a nested array?

No. Datatable renders data per row by array index.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.