New to Kendo UI for jQuery? Download free 30-day trial

Gantt for ASP.NET MVC Initialized in Container Does Not Render Properly

Environment

Product Progress® Telerik® UI Gantt for ASP.NET MVC

Description

My Gantt chart is placed in PanelBar item content that is not initially visible. When activating this item, the Gantt does not render properly.

Cause

The Gantt was initialized in a hidden (display: none;) container.

Solutions

  1. Use the deferred initialization of the Gantt.

    @(Html.Kendo().Gantt<InPanelBar.Models.TaskViewModel, InPanelBar.Models.DependencyViewModel>()
    .Name("Gantt")
    ...
    .Deferred()
    )
    
  2. Initialize the widget on the first activate event of the PanelBarItem that contains it.

    function onActivate(e) {
        var item = e.item;
        var title = $(item).find('a.k-header').text();
        var gantt = $('#Gantt').getKendoGantt();
    
        if (title === "Add Contenuti" && !gantt) {
            @Html.Kendo().DeferredScriptsFor("Gantt", false);
        }
    }
    

See Also

In this article