Completed
Last Updated: 07 Aug 2024 15:13 by ADMIN
Release 2024.3.806 (2024 Q3)
Zander
Created on: 09 Jul 2024 10:28
Category: GanttView
Type: Bug Report
1
RadGanttView: DivideByZero exception when the control is loaded
In this particular case, the RadScheduler is integrated with the RadGanttView. When the controls are loading there is a moment when the RadGanttView control is not fully loaded and its children elements are measured. In that case, DivideByZero exception will be thrown as the Children.Count of the RadGanttView is used in the size calculations. 
1 comment
ADMIN
Dinko | Tech Support Engineer
Posted on: 09 Jul 2024 10:40

Hi Zander,

Thank you for reporting this. As a workaround, we can add additional checks in the MeasureOverride and ArrangeOveride methods of the GanttViewTimelineItemBottomStackElement.

public class CustomGanttViewTimelineElementProvider : GanttViewTimelineElementProvider
{
    public CustomGanttViewTimelineElementProvider(GanttViewGraphicalViewElement owner) : base(owner)
    {

    }
    public override IVirtualizedElement<GanttViewTimelineDataItem> CreateElement(GanttViewTimelineDataItem data, object context)
    {
        GanttViewTimelineItemElement element = this.OnItemElementCreating(data);

        return new CustomGanttViewTimelineItemElement(data, Owner);
    }
}

public class CustomGanttViewTimelineItemElement : GanttViewTimelineItemElement
{
    public CustomGanttViewTimelineItemElement(GanttViewTimelineDataItem data, GanttViewGraphicalViewElement graphicalViewElement) : base(data, graphicalViewElement)
    {

    }
    public override GanttViewTimelineItemBottomStackElement CreateTimelineItemBottomStackElement()
    {
        return new CustomGanttViewTimelineItemBottomStackElement();
    }
}

public class CustomGanttViewTimelineItemBottomStackElement : GanttViewTimelineItemBottomStackElement
{
    public CustomGanttViewTimelineItemBottomStackElement() : base()
    {

    }
    protected override SizeF MeasureOverride(SizeF availableSize)
    {
        if (this.Children.Count == 0)
        {
            return availableSize;
        }
        return base.MeasureOverride(availableSize);
    }
    protected override SizeF ArrangeOverride(SizeF finalSize)
    {
        if (this.Children.Count == 0)
        {
            return finalSize;
        }
        return base.ArrangeOverride(finalSize);
    }
}

protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    this.radGanttView1.GanttViewElement.GraphicalViewElement.TimelineContainer.ElementProvider = new CustomGanttViewTimelineElementProvider(this.radGanttView1.GanttViewElement.GraphicalViewElement);
    this.radGanttView1.DataProvider = new GanttViewIntegrationProvider(this.radScheduler1);
}

It will be better to change the ElementProvider before populating the RadGanttView control with data.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.