Introduction
A WireBootstrap DataTable is a JavaScript class that contains an array of objects much like records in a database table. The data table contains dozens of methods for working with the array of objects including filers, transformations, and calculations. This class is located at wire.data.DataTable.
The example below creates a new DataTable from an array of objects. The raw array is put into a public property called Rows. Also, a Columns array is created that contains information about each column in the data table.
1
let users = [
2
{ Users: "jkratz", FullName: "Jamie Kratz" },
3
{ Users: "pdougherty", FullName: "Pat Dougherty" }
4
];
5
6
let table = new wire.data.DataTable(rows);
7
8
const rows = table.Rows;
9
10
const columns = table.Columns;
Copied!
Note, it's a good idea to use let or var scope when declaring arrays of rows to be used with a data table. The array sits inside a data table as a reference and not a copy so using operations on the data table that are designed to change the data or the array will error if the array is declared using a const. However, if the table is being created for read-only purposes, it's safe to use a const.
Copy link