Mappings
- 2 minutes to read
When you bind the GanttControl to a data source, you need to map the GanttNode properties to data source fields.
In real-world applications, the names of the database fields are usually fixed, and you cannot change them. Mappings are used to adjust the GanttControl data model to the existing data model.
| Mapping | Data Type | Description |
|---|---|---|
| NameMapping | String | Maps to the GanttNode.Name property. Provides a path to a data field that stores the task’s name. |
| ProgressMapping | Double | Maps to the GanttNode.Progress property. Provides a path to a data field that stores the task’s progress. |
| StartDateMapping | DateTime | Maps to the GanttNode.StartDate property. Provides a path to a data field that stores the task’s start date. |
| FinishDateMapping | DateTime | Maps to the GanttNode.FinishDate property. Provides a path to a data field that stores the task’s finish data. |
| DurationMapping | TimeSpan | Maps to the GanttNode.Duration property. Provides a path to a data field that stores the task’s duration. |
| BaselineStartDateMapping | DateTime | Maps to the GanttNode.BaselineStartDate property. Provides a path to a data field that stores the task baseline’s start date. |
| BaselineFinishDateMapping | DateTime | Maps to the GanttNode.BaselineFinishDate property. Provides a path to a data field that stores the task baseline’s finish date. |
| BaselineDurationMapping | TimeSpan | Maps to the GanttNode.BaselineDuration property. Provides a path to a data field that stores the task baseline’s duration. |
The code sample below demonstrates how to specify mappings.
<dxgn:GanttControl ItemsSource="{Binding Tasks}">
<dxgn:GanttControl.View>
<dxgn:GanttView
AutoExpandAllNodes="True"
TreeDerivationMode="Selfreference"
KeyFieldName="Id"
ParentFieldName="ParentId"
StartDateMapping="Start"
FinishDateMapping="Finish"
NameMapping="Name" />
</dxgn:GanttControl.View>
</dxgn:GanttControl>
Tip
You have no need to specify mappings when the GanttControl is bound to a collection of GanttTask objects.
You can use the Mapping.Converter property to specify a value converter for your data:
<dxgn:GanttView.StartDateMapping>
<dxgn:Mapping Path="BaselineStartDate" Converter="{StaticResource ...}"/>
</dxgn:GanttView.StartDateMapping>