DataTable Clone Example

This example shows you how to create a clone of a datatable. The cloned datatable is a new instance and modifications to the cloned datatable do not modify the original datatable and vice versa.

Smartsite SXML CopyCode image Copy Code
{buffer.set(table1, datatable.createempty(Name, Age))}
{datatable.rows.add($table1, 'Peter', 12)}
{datatable.rows.add($table1, 'Fred', 35)}

{buffer.set(table2, datatable.clone($table1))}
{datatable.setvalue($table2, 1, Name, 'Peter Pan')}
{datatable.setvalue($table2, 2, Name, 'Fred Flintstone')}

Original table:
{datatable.simpleformat($table1)}

Cloned and modified table:
{datatable.simpleformat($table2)}
Example Result CopyCode image Copy Code
Original table:
Name=Peter; Age=12
Name=Fred; Age=35

Cloned and modified table:
Name=Peter Pan; Age=12
Name=Fred Flintstone; Age=35
SXML