How to set the Blazor Gantt Chart zoom in to fit when it was first rendered

Answer:

We can set the Gantt to be zoomed to fit when it was first rendered using the dataBound event. Please find the below code snippet.

@code{

//..

public SfGantt Gantt;

public void dataBound()

{

if (this.Gantt != null)

{

this.Gantt.FitToProject();

}

}

//..

}


Find the sample to set the Blazor Gantt Chart zoom in to fit when it was first rendered fromhere.

2 Replies

VA Vangi August 21, 2021 07:12 AM UTC

In the Syncfusion.Blazor.Gantt package version 19.2.0.49 there is no DataBound method in the GanttEvents and no FitToProject​ method for the Gantt object. Please update the answer with the latest methods.



MS Monisha Sivanthilingam Syncfusion Team August 23, 2021 06:21 AM UTC

Hi Vangi, 
 
We can achieve your requirement by making use of the Created event. We have also changed the name of the FitToProject method to ZoomToFitAsync since version v19.2.44. The following code snippets demonstrate the solution. 
 
Index.razor 
 
public void Created(Object args) 
{ 
  this.Gantt.ZoomToFitAsync(); 
} 
 
 
We have also prepared a sample for your reference. 
 
Please contact us if you require any further assistance. 
 
Regards, 
Monisha. 


Loader.
Up arrow icon