DataTable Columns Add/Remove Example

This example shows you how to add and remove a column from a datatable.

Smartsite SXML CopyCode image Copy Code
<se:xmldatatable save="mytable" resulttype="datatable">
    <se:row>
        <se:col name="FirstName">Chris</se:col>
        <se:col name="LastName">Labree</se:col>
    </se:row>
</se:xmldatatable>

=== Columns: FirstName, LastName
{buffer.get(mytable)}

=== Columns: FirstName, LastName, Phone
{datatable.columns.add($mytable, Phone)}
{buffer.get(mytable)}

=== Columns: FirstName, phone
{datatable.columns.remove($mytable, LastName)}
{buffer.get(mytable)}
Example Result CopyCode image Copy Code
=== Columns: FirstName, LastName
SXMLDataTable (Name=DataTable; Rows=1; Columns=FirstName,LastName)

=== Columns: FirstName, LastName, Phone

SXMLDataTable (Name=DataTable; Rows=1; Columns=FirstName,LastName,Phone)

=== Columns: FirstName, phone

SXMLDataTable (Name=DataTable; Rows=1; Columns=FirstName,Phone)
SXML