Completed
Last Updated: 01 Jun 2015 10:34 by ADMIN
ADMIN
Dimitar
Created on: 17 Apr 2015 13:49
Category: GanttView
Type: Bug Report
1
FIX. RadGanttView - the start/end of the summary task is automatically changed when the control is bound.
To reproduce:
public RadForm1()
{
    InitializeComponent();
    DataTable tasks = new DataTable("Tasks");
    tasks.Columns.Add("Id", typeof(int));
    tasks.Columns.Add("ParentId", typeof(int));
    tasks.Columns.Add("Title", typeof(string));
    tasks.Columns.Add("Start", typeof(DateTime));
    tasks.Columns.Add("End", typeof(DateTime));
    tasks.Columns.Add("Progress", typeof(decimal));

    DataTable links = new DataTable("Links");
    links.Columns.Add("StartId", typeof(int));
    links.Columns.Add("EndId", typeof(int));
    links.Columns.Add("LinkType", typeof(int));

    tasks.Rows.Add(1, 0, "Summary task title", new DateTime(2010, 10, 8), new DateTime(2010, 10, 18), 30m);
    tasks.Rows.Add(2, 1, "First child task title", new DateTime(2010, 10, 10), new DateTime(2010, 10, 12), 10);
    tasks.Rows.Add(3, 1, "Second child task title", new DateTime(2010, 10, 12), new DateTime(2010, 10, 15), 20m);
    tasks.Rows.Add(4, 1, "Milestone", new DateTime(2010, 10, 15), new DateTime(2010, 10, 15), 0m);

    links.Rows.Add(2, 3, 1);
    links.Rows.Add(3, 4, 1);

    DataSet data = new DataSet();
    data.Tables.Add(tasks.Copy());
    data.Tables.Add(links);

    this.radGridView1.DataSource = tasks;
    radGridView1.BestFitColumns();

    this.radGanttView1.CreateDataItem += radGanttView1_CreateDataItem;
    this.radGanttView1.AllowSummaryEditing = true;
    this.radGanttView1.GanttViewElement.TaskDataMember = "Tasks";
    this.radGanttView1.GanttViewElement.ChildMember = "Id";
    this.radGanttView1.GanttViewElement.ParentMember = "ParentId";
    this.radGanttView1.GanttViewElement.TitleMember = "Title";
    this.radGanttView1.GanttViewElement.StartMember = "Start";
    this.radGanttView1.GanttViewElement.EndMember = "End";
    this.radGanttView1.GanttViewElement.ProgressMember = "Progress";
    this.radGanttView1.GanttViewElement.LinkDataMember = "Links";
    this.radGanttView1.GanttViewElement.LinkStartMember = "StartId";
    this.radGanttView1.GanttViewElement.LinkEndMember = "EndId";
    this.radGanttView1.GanttViewElement.LinkTypeMember = "LinkType";

    this.radGanttView1.GanttViewElement.DataSource = data;

    this.radGanttView1.Columns.Add("Start");
    this.radGanttView1.Columns.Add("End");
    this.radGanttView1.Columns.Add("Progress");

    this.radGanttView1.GanttViewElement.GraphicalViewElement.TimelineStart = new DateTime(2010, 10, 7);
    this.radGanttView1.GanttViewElement.GraphicalViewElement.TimelineEnd = new DateTime(2010, 12, 10);
}
You will notice that the start and end of the summary task are changed in the gantt view.

Workaround:
void radGanttView1_CreateDataItem(object sender, CreateGanttDataItemEventArgs e)
{
    e.Item = new MyGanttViewDataItem();
}

public class MyGanttViewDataItem : GanttViewDataItem
{
    protected override void OnChildAdded(GanttViewDataItem child)
    {
        if (this.Parent != null && !this.GanttViewElement.AllowSummaryEditing)
        {
            base.OnChildAdded(child);
        }
    }

    protected override void OnChildRemoved(GanttViewDataItem child)
    {
        if (this.Parent != null && !this.GanttViewElement.AllowSummaryEditing)
        {
            base.OnChildRemoved(child);
        }
    }
}

0 comments