Introduction to Atlas Controls in Namespace Sys.Data – DataSource and XMLDataSource
Dflying | 14 April, 2006 06:14Since there are no introductions or official documents about the Atlas controls in namespace Sys.Data, and data accessing is so important a part is current web applications, I decided to share some of my ideas and experiences on this part of Atlas by a series of posts. Hope may help. Please keep in mind that this series is just the introductions. That is, I will only tell how to use these controls but not how they are implemented or worked. If you are interested in the more advanced topics, please be a little patient for I prefer finishing this kind of introduction series firstly. By the way, I am still in the progress of learning, so anything incorrect please point me out directly. And, any ideas please shout out by commenting down.
You have to manage data in most of your web applications. I mean retrieving and displaying to user and saving back to database after modifying. This is a common task that we have to perform in almost every project, so ASP.NET abstract it as a build-in object, DataSource. Atlas client side script library, as well as ASP.NET, has the same concept of DataSource.
There are two kinds of DataSource in Atlas:
- Sys.Data.DataSource: represents a tabular data structure such as the result of a query to the database. Similar to the SQLDataSource object in ASP.NET. This control can be used as the client side data source of ListView (see: Display Listible Data Using ASP.NET Atlas ListView Control) and ItemView (see: Display One Item in a Collection using ASP.NET Atlas ItemView Control) controls. You can load data from server and save the changes back to server after user modified.
- Sys.Data.XMLDataSource: represents a hierarchy data structure such as an XML file. Similar to the XMLDataSource object in ASP.NET. This control can be used as the client side data source of XSLTView (introduction coming soon) control. This is the read only data source that you can only read data and show it to user but not save the modifications back to server.
Now let’s go over the two data source controls above.
- Sys.Data.DataSource:The DataSource object has following properties:
- data: The data retrieves from database and stores in the client side.
- autoLoad: Boolean value indicates whether this data source control will load data automatically from server after initializing. You should use initialData instead of using this property if you want to load the data with the page loads, for it needs an extra round to server right after the page loads.
- initialData: Initial data come with the page. There’s a scenario that there should be some initial data on your page when user hitting the page at the first time, for example, the first page of records of your list. Then we can use an Atlas server side control InitialData to send the data with the page source, to avoid querying server again right after page loads.
- isDirtyAndReady: Indicates whether this DataSource finished loading data and the data is not empty and the data is not changed.
- isReady: Indicates whether this DataSource finished loading data from server. You may bind this property to a data bind control’s enabled property to disable the binding control when the data is in loading.
- rowCount: Rows count of the data.
- serviceURL: URL of the Web Service where the DataSource can retrieve data from. You should always set this property.
- parameters: Parameters append to the service URL. Only used when serviceType is set to Handler.
- serviceType: Type of this service. Can be set to DataService or Handler. Default and recommended value is DataService, which means your service is derived from Microsoft.Web.Services.DataService and has the build-in supports for CRUD operations.
Following methods:
- load: Retrieves data from server.
- save: Saves client side changes back to server. Only works if serviceType is set to DataService.
And following event:
- dataAvailable: Gets fired when loading data completed.
For demos about this control please refer to: Display Listible Data Using ASP.NET Atlas ListView Control and Display One Item in a Collection using ASP.NET Atlas ItemView Control
Sys.Data.XMLDataSource
The XMLDataSource object has following properties:
- autoLoad: Boolean value indicates whether this data source control will load data automatically from server after initializing. You should use initialDocument instead of using this property if you want to load the data with the page loads, for it needs an extra round to server right after the page loads.
- data: The parsed xml data from property document.
- document: The string contains an xml document.
- initialDocument: Similar with initialData property of DataSource. And you should always try to use this property when your data comes with the page.
- isReady: Similar with the one in DataSource. Indicates whether this data source finished loading data and parsing the xml.
- parameters: Parameters append to the service URL.
- serviceURL: URL of the Web Service where the XMLDataSource can retrieve data from. You should always set this property.
- xpath: The xpath string used for query the document property and set the data property.
Following methods:
- load: Retrieves data from server and parse to data property.
And following event:
- dataAvailable: Gets fired when loading data completed.
Demos for this control is coming soon.
Posted in
Atlas.
Comment: (0).
Trackbacks:(639).
Permalink
«Next post |
Previous post»




