August 17, 2018, 03:23:50 PM

See more Support incidents in our old archived forum.

Author Topic: Expand / Collapse - Get/Set for each TreeItem  (Read 1347 times)

vtunc

  • Customers
  • Newbie
  • *
  • Posts: 7
Expand / Collapse - Get/Set for each TreeItem
« on: March 30, 2017, 04:22:34 PM »
Hi,

Is it possible to store the status for each TreeItem, whether the item is expaned or collapsed? I have a two-dimensional list of elements. Meetings can be booked on each element. Now I want to save the layout so that after a new loading of the Gantt, the elements are displayed in the same form.

Here a short Example:
► Folder1          (collapsed -> Should be saved)
▼ Folder2          (expanded -> Should be saved)
   Assignment1    (no Meetings)
   ▼ Assignment2    (expanded -> Should be saved)
       Meeting1
       Meeting2
   ► Assignment3    (collapsed -> Should be saved)
Assignment4

My question now: Is it possible to save and restore the status? If yes how?

Thanks and Regards,
Martin

Rajagopal

  • RQ Members
  • Jr. Member
  • *
  • Posts: 98
Re: Expand / Collapse - Get/Set for each TreeItem
« Reply #1 on: March 31, 2017, 12:53:44 PM »
Martin,

We are looking on this, will update you soon.


Thanks
Raja

Rajagopal

  • RQ Members
  • Jr. Member
  • *
  • Posts: 98
Re: Expand / Collapse - Get/Set for each TreeItem
« Reply #2 on: April 04, 2017, 04:06:06 PM »
Martin,

You can listen for "NodeExpansionStateChanged" event of FlexyTree in our Gantt to load the Gantt with persisted expanded state from Data and vice versa. Here is the code usage,

Code: [Select]
public MainPage()
{
    InitializeComponent();

    // Time scale zoom setting. Default is 25
    this.fxgantt.BaseTimeUnitWidth = 40;

    this.fxgantt.ItemsSource = SampleProjectData.GetSampleData();

    this.fxgantt.TemplateApplied += new EventHandler(fxgantt_TemplateApplied);
}

bool onGanttLoad = true;
void fxgantt_Loaded(object sender, RoutedEventArgs e)
{
    this.onGanttLoad = false;
}
void FlexyTree_NodeExpansionStateChanged(object sender, NodeExpansionStateChangedEventArgs e)
{
    if (e.TreeViewItem.DataContext is Group)
    {
        if (this.onGanttLoad)
            // Update Gantt expansion state from Data.
            e.TreeViewItem.IsExpanded = ((Group)e.TreeViewItem.DataContext).IsExpanded;
        else
            // Update Data expansion state from Gantt.
            ((Group)e.TreeViewItem.DataContext).IsExpanded = e.TreeViewItem.IsExpanded;
    }
}

Thanks
Raja

vtunc

  • Customers
  • Newbie
  • *
  • Posts: 7
Re: Expand / Collapse - Get/Set for each TreeItem
« Reply #3 on: April 05, 2017, 10:13:38 AM »
Raja,

Thank you for your quick help.

Could be my error that I have not informed you that I use the FlexyTable instead of the FlexyTree. Sorry for the fact that I can not find the solution myself so quick, but is there a possibility in FlexyTable?

Thanks,
Martin

Rajagopal

  • RQ Members
  • Jr. Member
  • *
  • Posts: 98
Re: Expand / Collapse - Get/Set for each TreeItem
« Reply #4 on: April 05, 2017, 02:03:19 PM »
Martin,

FlexyTable uses FlexyTree internally. So, you can listen for "NodeExpansionStateChanged" event of FlexyTree as we recommended. Here is the code for subscribing the event,

Code: [Select]
void fxgantt_TemplateApplied(object sender, EventArgs e)
{
    this.fxgantt.FlexyTree.NodeExpansionStateChanged += new NodeExpansionStateChangedEventHandler(FlexyTree_NodeExpansionStateChanged);
}

Thanks
Raja

vtunc

  • Customers
  • Newbie
  • *
  • Posts: 7
Re: Expand / Collapse - Get/Set for each TreeItem
« Reply #5 on: April 11, 2017, 12:52:27 PM »
Hi Raja,

Thank you! This solution works very fine. =)

Thanks,
Martin