Completed
Last Updated: 29 Sep 2014 09:07 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 20 Aug 2014 10:24
Category: GanttView
Type: Bug Report
1
FIX. RadGanttView - Setting the e.ItemElement.TaskElement.Text in the GraphicalViewItemFormatting event does not take effect
To reproduce: add a RadGanttView and populate it with data. Use the  GraphicalViewItemFormatting event in order to change the e.ItemElement.TaskElement.Text. However, the changes are not applied.

Workaround:
 private void radGanttView1_GraphicalViewItemFormatting(object sender, GanttViewGraphicalViewItemFormattingEventArgs e)
 {
     e.ItemElement.Tag = "Custom text";
 }

 public class CustomRadGanttView : RadGanttView
 {
     protected override RadGanttViewElement CreateGanttViewElement()
     {
         return new CustomRadGanttViewElement();
     }

     public override string ThemeClassName  
     { 
         get 
         { 
             return typeof(RadGanttView).FullName;  
         }
     }
 }

 public class CustomRadGanttViewElement : RadGanttViewElement
 {
     public CustomRadGanttViewElement()
     {
     }

     protected override Type ThemeEffectiveType     
     { 
         get    
         { 
             return typeof(RadGanttViewElement);     
         }
     }
     
     protected override GanttViewGraphicalViewElement CreateGraphicalViewElement(RadGanttViewElement ganttView)
     {
         return new CustomGanttViewGraphicalViewElement(ganttView);
     }
 }

 public class CustomGanttViewGraphicalViewElement : GanttViewGraphicalViewElement
 {
     public CustomGanttViewGraphicalViewElement(RadGanttViewElement ganttView) : base(ganttView)
     {
     }

     protected override Type ThemeEffectiveType     
     { 
         get    
         { 
             return typeof(GanttViewGraphicalViewElement);     
         }
     }
     
     protected override IVirtualizedElementProvider<GanttViewDataItem> CreateElementProvider()
     {
         return new CustomGanttViewVirtualizedElementProvider(this);
     }
 }

 public class CustomGanttViewVirtualizedElementProvider : GanttViewVirtualizedElementProvider
 {
     public CustomGanttViewVirtualizedElementProvider(GanttViewBaseViewElement owner) : base(owner)
     {
     }

     public override IVirtualizedElement<GanttViewDataItem> CreateElement(GanttViewDataItem data, object context)
     {
         IVirtualizedElement<GanttViewDataItem> taskElement = base.CreateElement(data, context) ;
         if (taskElement is GanttViewTaskItemElement)
         {
             FieldInfo fi = typeof(GanttViewVirtualizedElementProvider).GetField("owner", BindingFlags.NonPublic | BindingFlags.Instance);
             GanttViewBaseViewElement owner = fi.GetValue(this) as GanttViewBaseViewElement ;
               
             return new CustomGanttViewTaskItemElement(owner as GanttViewGraphicalViewElement);
         }

         return taskElement;
     }
 }

 public class CustomGanttViewTaskItemElement:GanttViewTaskItemElement
 {
     public CustomGanttViewTaskItemElement(GanttViewGraphicalViewElement owner) : base(owner)
     {
     }

     public override void Synchronize()
     {
         base.Synchronize();
         
         if (this.Tag != null)
         {
             this.TaskElement.Text = this.Tag.ToString();
         }
     }
 }
0 comments