Adding Other Data Sources

You can easily associate additional, separate data sources, such as a contacts list, with a C1Scheduler control. In this example, we have already associated the Holidays data source with the Calendar screen, and now we are going to add a Contacts data source. To do this, follow these steps:

1.   First, add the data source to the project as you did for the C1Scheduler data source, only you must set two required properties instead of seven. The Id and Text properties must be included and marked as required. You can also add other properties, if you like, but this is optional. Set the Id and Text properties as seen in the following image:



2.   In the Solution Explorer, double-click the screen you are associating with the separate data source.

3.   Select C1Scheduler and click Add Data Item to add the desired query, Contacts, to the screen.



4.   In the Add Data Item dialog box, select Query, choose the new data source, and click OK. When selecting the data source, choose the TableName(All) return type to ensure the collection is returned.

5.   Click Add drop-down list and select Contacts to add the collection to the end of the screen layout. Then change the default control name, Data Grid, to C1Contacts as shown in the following figure.


The mapping between the Contacts table properties and the C1Contacts storage model is handled by the C1ContactPlaceholder element, similar to the way the C1Scheduler storage model is handled by the C1AppointmentPlaceholder element.

If you select the table in the screen designer and view the Visual Studio Properties window, you'll notice the Control Type for the Contacts table is Default (C1ContactPlaceholder).

Just as you must do with the C1AppointmentPlaceholder, the Primary Key property must be set to the name of an integer, string, or GUID property that uniquely identifies a contact record in the data source. The remaining drop-down controls let you specify string property names, as appropriate.

6.   Set the properties as shown in the following image:



Repeat this process for the C1Categories and C1Resources storage models, if desired. Mappings are handled by the C1CategoryPlaceholder and C1ResourcePlaceholder, respectively. The properties are the same as for the ContactsTemplate.

ComponentOne Logo
Send comments about this topic to ComponentOne.
Copyright © GrapeCity, inc. All rights reserved.