In this post we are going to touch the key client side data components of Atlas – the DataTable, which is used to represent a tabular data structure. The DataTable
object connects the actual data – the DataSource and the UI control – the ListView. It is the data field of a DataSource
object, and can also be decorated by a DataView
object by filtering and sorting the rows or doing the page navigations. Here Atlas also shares the ASP.NET/ADO.NET concepts: the Atlas DataSource is similar with ADO.NET SqlDataSource, the Atlas DataTable is similar with ADO.NET DataTable and the Atlas ListView is similar with ASP.NET ListView. Pretty easy to understand, isn't it? A DataTable contains a collection of DataColumn
objects and a collection of DataRow
objects, so let's begin with the DataColumn and DataRow.
Sys.Data.DataColumn
The DataColumn
object is really simple, only following properties:
columnName: Column name string.
dataType: The type of data in this column.
defaultValue: The default value in this column.
isKey: Whether data in this column is the key of DataTable.
readOnly: Whether data in this column is read only.
Sys.Data.DataRow
Sys.Data.DataRow
object is a little bit of complex, there’s following properties:
$isDirty: Whether this row is modified and not submitted to server yet.
$index: The index of current row in DataTable.
$selected: Whether this row is selected.
And following event:
propertyChanged: gets fired when one of the above properties is changed.
Sys.Data.DataTable
Now let start the DataTable, the DataTable
object implements the Sys.Data.IData interface. Following properties:
columns: Current collection of DataColumn
objects. You may add/update/delete a column when get the collection.
keyNames: The collection of key columns’ columnName property.
length: Length of row collection.
isDirty: Whether the DataRow collection is changed and not submitted to server yet.
And following methods:
add: Add a new row to current DataTable.
clear: Delete all rows in current DataTable.
remove: Remove an existing row in current DataTable.
createRow: Create a new row based on current DataTable’s schema.
getChanges: Get the changes of current DataTable. There are three parts in the result.
updated: The updated row collection.
inserted: The added row collection.
deleted: The delete row collection.
getColumn: Get a DataColumn
object by column name.
getRow: Get a DataRow
object by row index.
getItem: The same to getRow method.
Also events:
collectionChanged: Gets fired when the DataRow collection is modified.
propertyChanged: Gets fired when one of the properties above is changes.