Change the Parent Summary on SelectedItemChanged

5 posts, 1 answers
  1. Marius
    Marius avatar
    9 posts
    Member since:
    Dec 2014

    Posted 15 Feb Link to this post

    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

     

     

     

  2. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 16 Feb Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Marius
    Marius avatar
    9 posts
    Member since:
    Dec 2014

    Posted 16 Feb in reply to Dess Link to this post

    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 ?

  5. Answer
    Dess
    Admin
    Dess avatar
    1609 posts

    Posted 17 Feb Link to this post

    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 in your project and add them anew by using the DLLs from your fresh installation. After that 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
  6. Marius
    Marius avatar
    9 posts
    Member since:
    Dec 2014

    Posted 17 Feb in reply to Dess Link to this post

    Thank you

    That sorted out my issue ;)

Back to Top
UI for WinForms is Visual Studio 2017 Ready