RadiantQ WPF Gantt
WBS Support
Previous Topic  Next Topic 

WBS Support


Work Breakdown Structure (WBS) codes are outline numbers that you can apply to tasks and edit to match your business needs.


You can setup a default outline numbering scheme which will be used by the gantt as the user adds/deletes/moves tasks around. And you can also allow your end-users to edit the WBS codes and provide their own for specific tasks.


NOTE: WBS is illustrated in the sample Samples\ProjectGantt\Misc\WBSEnabledTasks. Use that as a companion resource while you read through this topic.


Turning On WBS for tasks


To begin with, you can turn on this feature by providing a method to the GanttControl.ProvideWBSID that will compute the WBS for a given task. For example:

        public MainPage()

        {

            InitializeComponent();


            .......


            this.ganttControl.ProvideWBSID = this.ProvideWBSIDHandler;


            this.ganttControl.ItemsSource = taskItems;


        }

        // Generate WBS codes of the form 1.10.1

        void ProvideWBSIDHandler(object sender, ProvideDefaultWBSIDEventArgs args)

        {

            string childIndex = (args.GetActivityChildIndex() + 1).ToString();

            if (args.Activity.Parent == null)

                args.NewWBSID = childIndex;

            else

                args.NewWBSID = args.Activity.Parent.DefaultWBSID + "." + childIndex;

        }


This will set an corresponding, appropriate WBS code on all the activities that are in the model. You can visualize this WBS in the Gantt UI by adding a column to the Gantt's grid as follows:


    <Grid x:Name="LayoutRoot" Background="White">

        <Grid.Resources>

            <data:DataGridTemplateColumn x:Key="wbsIDColumn" Header="WBS" >

                <data:DataGridTemplateColumn.CellTemplate>

                    <DataTemplate>

                        <TextBlock Text="{Binding Activity.WBSID}" VerticalAlignment="Center"

                                                      Margin="2,0,0,0"></TextBlock>

                    </DataTemplate>

                </data:DataGridTemplateColumn.CellTemplate>

            </data:DataGridTemplateColumn>

           

        </Grid.Resources>

     </Grid>


        void ganttControl_TemplateApplied(object sender, EventArgs e)

        {

            this.ganttControl.GanttTable.Columns.Insert(1, this.LayoutRoot.Resources["wbsIDColumn"] as DataGridTemplateColumn);

        }


This will add the WBS code to all the activities, even as you move the tasks around.


Gantt With WBS


To access a WBS of any activity, you can use the IActivity.WBSID string property.


Persisting WBS Codes

You can now optionally choose to persist the WBS codes into your database by setting up the WBSIDBinding property.


        <radiantq:GanttControl x:Name="ganttControl"  WBSIDBinding="{Binding WBSID, Mode=TwoWay}" ........... >


This will persist the WBS code assigned to a task into your data source that you can reference from outside the gantt, if necessary.


Enable End-User Editing

You can also optionally choose to allow the end-user to edit the WBS codes assigned to a task. First enable editing in the WBS column template as below:

            <data:DataGridTemplateColumn x:Key="wbsIDColumn" Header="WBS" >

                .......

                <data:DataGridTemplateColumn.CellEditingTemplate>

                    <DataTemplate>

                        <TextBox Text="{Binding Activity.WBSID, Mode=TwoWay}"

                                                    VerticalAlignment="Center"></TextBox>

                    </DataTemplate>

                </data:DataGridTemplateColumn.CellEditingTemplate>

            </data:DataGridTemplateColumn>


User can then start editing and specify any string value they see fit as the WBS code for any task:

WBS Editing


The gantt will then preserve this WBS code as the task is moved around in the hierarchy. To distinguish such user-specified WBS and auto-generated WBS, the activity interface has the following properties:


IActivity.WBSID - The current WBSID assigned to this activity. This could be the auto-generated one or end-user edited one.

IActivity.IsAutoWBSID - This bool property indicates if the above WBSID property has a auto-generated value (true) or a end-user provided value(false).

IActivity.DefaultWBSID - The auto-generated WBSID for this activity.


The end-user can also clear a custom WBSID that he might have set on a task by simply editing and clearing the text in the TextBox. This will make the gantt assign the auto generated WBS value to the task.


The edited values are then persisted into the database if the WBSIDBinding is set.


Note that while persisting, to distinguish auto-generated and custom WBS values, the custom values are prefixed with a "*". If you browse these WBS values directly in the database, remember to trim this "*" out before you use it.




� RadiantQ 2009 - 2019. All Rights Reserved.