First, some details about the table:
Column instance.
Columns are identified by their indexes, starting at zero.Row instance. Each row must
have an unique, assigned identifier.Here is the basic usage, assuming that a div with id="container" already exists:
//Create the table with id=tab
var table = new JavaScripTable("tab", "container");
//Add a column just with a header text
table.addColumn("Name");
//Add the column with the header text and type
table.addColumn(new Column("Income", JST_TYPE_NUMBER));
//Add a column just with a header text and customize it later
var birthDateColumn = table.addColumn("Birth Date");
birthDate.type = JST_TYPE_DATE;
//Add a column and customize it using the with statement
with (table.addColumn("Gender")) {
width = "75px";
align = "center";
}
//Add a few rows
table.addRow(new Row(1, ["John", 4065.51, new Date(1978, 1, 1), "male"]));
table.addRow(new Row(2, ["Mary", 5016.30, new Date(1963, 8, 12), "female"]));
table.addRow(new Row(3, ["Peter", 2429.46, new Date(1982, 9, 20), "male"]));
//Render the table
table.render();
| Previous: Introduction to JavaScripTable |
Table of Contents | Next: Table properties |