Each DataTable column contains meta data about a column in the table. Below is a list of the properties on a DataTable column.


Property
Description
Id
The unique identifier for a column. This is an optional field that may be supplied by a service provider. If available, it usually correlates to a unique key in a database for the column within an entity store or table.
Name
The name of the column.
Title
The optional descriptive title for a column. If supplied, this will be used in user interface components in place of Name.
DataType
This is the system generated data type of the column. This is usually supplied by the service provider and is the native data type of the column inside the source database.
Type
This is the common data type for the column. It provides a standard type for WireBootstrap code. It is usually translated from the DataType property of the service provider. Valid values include int, string, boolean, datetime, and guid.



New Columns


Use addColumn to add new columns to a table.


 
var table = new eb.data.DataTable([ 
    {product: "apples", order: "PRN001", quantity: 10},
    {product: "oranges", order: "PRN002", quantity: 15},
    {product: "apples", order: "PRN003", quantity: 20}    
]);
    
 
// add a new column with a static value for all rows
table.addColumn("Static Column").value("static data");
 
// add the same but make it HTML
table.addColumn("HTML Column").type("html").value("<div>static data</div>");
 
// add a calculated column with a format to 2 decimal places
table.addColumn("Calculated Column").calc(function(row, index, table){
    return row["quantity"] * .111;
}).format("N2");
 
// add a new column that contains the index position for each row
table.addColumn("Identity Column").index();


Note, the Title property will automatically be set to a space-delimited equivalent of the Name.


// this Title will default to 'My Column'
table.addColumn("MyColumn");
 
// this sets the Title to 'My Column Title'
table.addColumn("MyColumn").title("My Column Title");


Maintenance


Use the methods illustrated in the example below to maintain DataTable columns.


// get the product column object and change it's title to Widget
var column = table.getColumn("product");
column.Title = "Widget";
 
// returns Title if there is one otherwise returns Name
var title = table.getColumnTitle("product");
 
// remove the product column
table.removeColumn("product");
 
// rename the product column to widgets
table.renameColumn("product", "widgets");
 
// get the distinct list of products
var values = table.distinctArray("product");