Completed
Last Updated: 13 Aug 2018 08:13 by Dimitar
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 08 Aug 2018 11:07
Category: GanttView
Type: Bug Report
2
FIX. RadGanttView - RowNotInTableException when clearing the DataSet in the DragDropService.Stopped event
To reproduce: run the sample project and try to move a task.

Workaround:

 Timer timer = new Timer();

        private void DragDropService_Stopped(object sender, EventArgs e)
        {
            timer = new Timer();
            timer.Interval = 300;
            timer.Tick += timer_Tick;
            
        }

        private void timer_Tick(object sender, EventArgs e)
        {
            timer.Stop();
            data.Tables["Tasks"].Clear();
        }

Workaround 2:

        private void radGanttView1_ItemElementCreating(object sender, Telerik.WinControls.UI.GanttViewItemElementCreatingEventArgs e)
        {
            if (e.Item.Items.Count == 0 && e.ViewElement is GanttViewGraphicalViewElement)
            {
                e.ItemElement = new MyGanttViewTaskItemElement(e.ViewElement as GanttViewGraphicalViewElement); 
            }
        }

        public class MyGanttViewTaskItemElement : GanttViewTaskItemElement
        {
            public MyGanttViewTaskItemElement(GanttViewGraphicalViewElement ganttViewBaseViewElement) : base(ganttViewBaseViewElement)
            {
            }
            
            protected override Type ThemeEffectiveType
            {
                get
                {
                    return typeof(GanttViewTaskItemElement);
                }
            }

            public override void Detach()
            {
                var obj = this.Data;
                this.Data.SuspendPropertyNotifications();
                base.Detach();
                obj.ResumePropertyNotifications(); 
            }

            public override void Synchronize()
            {
                DataSet ds = this.Data.GanttViewElement.DataSource as DataSet;
                if (ds != null && this.Data != null)
                {
                    DataRowView rowView = this.Data.DataBoundItem as DataRowView;
                    if (rowView != null && !RowExists(rowView.Row))//!ds.Tables[0].Rows.Contains(rowView.Row))
                    {
                        return;
                    }
                }
                base.Synchronize();
            }

            private bool RowExists(DataRow dataRow)
            {
                DataSet ds = this.Data.GanttViewElement.DataSource as DataSet;
                bool res = false;
                foreach (DataRow r in ds.Tables[0].Rows)
                {
                    if (r.Equals(dataRow))
                    {
                        return true;
                    }
                }
                return res;
            }
        }
Attached Files:
0 comments