This is a migrated thread and some comments may be shown as answers.

Change the Parent Summary on SelectedItemChanged

4 Answers 59 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
Marius
Top achievements
Rank 1
Marius asked on 15 Feb 2016, 10:28 AM

Hi All

I have implemented the gantview in a test winforms application, and I am just wondering if someone can assist me.

On the View, I drag a Task (Child) Item, and thus changes the start or end date.

Now a very Basic need, is that the Summary (Parent) gets updated too.

Here is a toned down version:

void radGanttView1_SelectedItemChanged(object sender, GanttViewSelectedItemChangedEventArgs e)
{
    try
    {
             if (e.Item.End > e.Item.Parent.End)
             {    
                    e.Item.Parent.End = e.Item.End;

            } 

           if (e.Item.Start < e.Item.Parent.Start)
          {
              e.Item.Parent.Start = e.Item.Start;
         }
     }
   catch { }
}

(View1)

Now this "WORKS" in the sense that if I click off the selected child (View2) , and then back on to it, the  Summary does update (View3), but I need it to be immediately

 

Regards

 

Marius

 

 

 

4 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 16 Feb 2016, 09:20 AM
Hello Marius,

Thank you for writing.

It is suitable to use the RadGanttView.ItemChanged event and detect whether the start or end date of an item is changed and update its parent accordingly. Here is a sample code snippet which result is illustrated at the attached gif file:
 
private void radGanttView1_ItemChanged(object sender, GanttViewItemChangedEventArgs e)
{
    if (e.PropertyName == "Start")
    {
        if (e.Item.Parent != null)
        {
            e.Item.Parent.Start = GetNewStart(e.Item.Parent);
        }
    }
    else if (e.PropertyName == "End")
    {
        if (e.Item.Parent != null)
        {
            e.Item.Parent.End = GetNewEnd(e.Item.Parent);
        }
    }
}
 
private DateTime GetNewEnd(GanttViewDataItem parentItem)
{
    DateTime end = DateTime.MinValue;
    foreach (GanttViewDataItem item in parentItem.Items)
    {
        if (end < item.End)
        {
            end = item.End;
        }
    }
    return end;
}
 
private DateTime GetNewStart(GanttViewDataItem parentItem)
{
    DateTime start = DateTime.MaxValue;
    foreach (GanttViewDataItem item in parentItem.Items)
    {
        if (start > item.Start)
        {
            start = item.Start;
        }
    }
    return start;
}

I hope this information helps. Should you have further questions I would be glad to help.
 
Regards,
Dess
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Marius
Top achievements
Rank 1
answered on 17 Feb 2016, 05:23 AM

Thank you Dess.

 

When was GanttViewItemChangedEventArgs  added ?

Our IT Policies is very strict, so I might not have the latest version, since I am unable to update it myself and have to request it from IT, since I get the error that GanttViewItemChangedEventArgs  could not be found ?

0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 Feb 2016, 10:56 AM
Hello Marius,

Thank you for writing back. 

The ItemChanged event was introduced in Q2 2015 SP1 (version 2015.2.728). Here is the release history for your reference: http://www.telerik.com/support/whats-new/winforms/release-history/ui-for-winforms-q2-2015-(version-2015.2.728)

You can download the latest version from your account, uninstall the previous version from Control Panel and install the latest one. Afterwards, remove all references your project and add them anew by using the DLLs from your fresh installation. After you should rebuild your project, close Visual Studio and open it again to make sure that no references are kept in the memory by Visual Studio.

You can find below listed two other options for upgrading to latest version:
http://docs.telerik.com/devtools/winforms/installation-deployment-and-distribution/visual-studio-extensions/automatic-latest-version-retrieval

http://docs.telerik.com/devtools/winforms/installation-deployment-and-distribution/visual-studio-extensions/upgrade-wizard

I hope this information helps. If you have any additional questions, please let me know.

Regards,
Dess
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Marius
Top achievements
Rank 1
answered on 17 Feb 2016, 11:05 AM

Thank you

That sorted out my issue ;)

Tags
GanttView
Asked by
Marius
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Marius
Top achievements
Rank 1
Share this question
or