We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Gantt don't load my json

Hi , I try to load gantt but  when i load a huge data the browser stop to work

the json has 1304 rows;

I put my json in attachament; Can you help with this problem

@(Html.EJ()
    .Gantt("AtividadeGantt")
    .Locale("pt-BR")   
    .TaskIdMapping("TaskID")        
    .IncludeWeekend(false)
    .EnableResize(true)
    .TaskNameMapping("TaskName")
    .ChildMapping("SubTasks")
    .StartDateMapping("StartDate")
    .EndDateMapping("EndDate")
    .DurationMapping("Duration")                                
    .ProgressMapping("Progress")
    .PredecessorMapping("Predecessor")
    .ResourceInfoMapping("ResourceID")
    .ResourceIdMapping("ResourceID")
    .ResourceNameMapping("ResourceName")    
    .HighlightWeekends(true)
    .SplitterPosition("50%")
    .TreeColumnIndex(1)        
    .AllowGanttChartEditing(true)
    .AllowSelection(true)
    .AllowColumnResize(true)
    .EnableVirtualization(true)
    .EnableContextMenu(false)    
    .ToolbarSettings(toolbar =>
    {
        toolbar.ShowToolbar(true);
                                  
        toolbar.ToolbarItems(new List<GanttToolBarItems>()
        {                                           
            GanttToolBarItems.Add,
            GanttToolBarItems.Edit,
            GanttToolBarItems.Delete,
            //GanttToolBarItems.Update,
            GanttToolBarItems.Cancel,
            GanttToolBarItems.Indent,
            GanttToolBarItems.Outdent,
            GanttToolBarItems.ExpandAll,
            GanttToolBarItems.CollapseAll
        }
        );
    })
    .EditSettings(edit =>
    {
        edit.AllowEditing(true);
        edit.AllowAdding(true);
        edit.AllowDeleting(true);
        edit.EditMode("cellEditing");                
    })
    .EditDialogFields(eve =>
                    {
                        eve.Field("TaskName").Add();
                        eve.Field("StartDate").Add();                        
                        eve.Field("EndDate").Add();
                        eve.Field("Duration").Add();
                        eve.Field("ResourceID").Add();
                        eve.Field("disciplina").Add();//To display custom column        
                        eve.Field("status_atividade").Add();//To display custom column
                        eve.Field("custo_direto").Add();//To display custom column                        
                        eve.Field("Predecessor").Add();
                        
                    })
    .AddDialogFields(eve =>
            {
                eve.Field("TaskName").Add();
                eve.Field("StartDate").Add();
                eve.Field("EndDate").Add();
                eve.Field("Duration").Add();
                eve.Field("ResourceID").Add();
                eve.Field("disciplina").Add();//To display custom column
                eve.Field("status_atividade").Add();//To display custom column
                eve.Field("custo_direto").Add();//To display custom column
                eve.Field("Predecessor").Add();             
            })
    .StripLines(eve=>
       {
           eve.Label("Hoje").Day(DateTime.Now.ToString("dd/MM/yyyy"))
               .LineColor("Darkblue").LineStyle("dotted")
               .LineWidth(2).Add();
       })                         
    .ClientSideEvents(eve =>
    {
        eve.Load("load");
        eve.ActionComplete("ActionComplete");
        eve.BeginEdit("beginEdit");
        eve.ActionBegin("CheckDelete");
        eve.Create("ganttCreate");
        //eve.ContextMenuOpen("contextMenuOpen");
    })    
    .DateFormat("dd/MM/yyyy")       
    .ScheduleStartDate(ViewBag.initialDate)
)
this is my load event 

function LoadGrid(id) {
        //For retrieving the Gantt control object
        
        var ganttObject = $("#AtividadeGantt").data("ejGantt");
 
        //ganttObject.setModel({ enableContextMenu: true });
 
        Ext.getBody().mask('Carregando...');
 
        $.ajax({
            type: "POST",
            url: "Atividade/LoadGanttAtividade",
            data: { idprojeto: idprojeto }
        })
        .success(function (data, st) {            
            Ext.get(document.body).unmask();            
            if (st == "success") {
                disciplinas = data.disciplinas;
                status_atividade = data.status;
                ganttObject.model.resources = data.resources;
                if (data.grid.length == 0)
                    ganttObject.setModel({ dataSource: [], scheduleStartDate: data.initialDate/*, resources: data.resources, toolbarSettings: { showToolbar: true }*/ });
                else
                    ganttObject.setModel({ dataSource: data.grid, scheduleStartDate: data.initialDate/*, resources: data.resources, toolbarSettings: { showToolbar: true }*/ });                
            }
            else {
                Ext.Msg.alert({
                    title: "Atenção",
                    msg: "Não foi possível carregar os dados",
                    buttons: Ext.Msg.OK,
                    icon: Ext.MessageBox.WARNING                    
                });               
            }
        })
        .error(function (XMLHttpRequest, textStatus, errorThrown) {
            Ext.get(document.body).unmask();
            Ext.Msg.alert({
                title: "Atenção",
                msg: "Não foi possível carregar os dados",
                buttons: Ext.Msg.OK,
                icon: Ext.MessageBox.WARNING
            });            
        });     
    }
Best regards,
Otto

Attachment: data_deda4446.rar

1 Reply

JD Jayakumar Duraisamy Syncfusion Team January 18, 2016 04:47 PM UTC

Hi Otto,

We regret for the inconvenience caused.

We have analysed the reported issue with your sample code and dataSource. We are unable to reproduce the issue. Because, LoadGrid() method was not called from anywhere and also we can’t render control without initial dataSource at load event. Hence we suggest you to use Create event to render control with your json dataSource. Please refer the below code snippet to render control by create event.


<script src="~/Scripts/data.js"></script> // json data


@(Html.EJ().Gantt("AtividadeGantt")   

    .TaskIdMapping("TaskID")

    .IncludeWeekend(false)

    .EnableResize(true)

         //…

         .ClientSideEvents(eve =>

    {

        eve.Create("ganttCreate");       

    })

)

@(Html.EJ().ScriptManager())

    <script type="text/javascript">             

        function ganttCreate(args) {           

        var ganttObj = $("#AtividadeGantt").data("ejGantt");      

        ganttObj.option("dataSource", data);


    }     

    </script>


We have also prepared a sample for your reference. Please find the sample in the following URL.

Sample: http://www.syncfusion.com/downloads/support/forum/121682/ze/MVCsampleSQL-805249858
Please let us know if you require further assistance on this.

Regards,

Jayakumar Duraisamy


Loader.
Live Chat Icon For mobile
Up arrow icon