[英]Rendering array data in Datatable
I want to display a (large amount) of data stored in an array from the fomrat: 我想显示来自fomrat的(大量)存储在数组中的数据:
records = ["First", "Second", "Third", "...", "last"];
I am using the following javascript to display the data. 我正在使用以下JavaScript来显示数据。
<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"]];
如果是,则将records
的表示切换到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. 否。Datatable按数组索引每行呈现数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.