Contents
- Set width and height
- Responsive with the parent container
Having trouble getting help?
Contact Support
Contact Support
Scrolling in Angular Gantt component
27 Apr 20245 minutes to read
The scrollbar will be displayed in the gantt when content exceeds the element width
or height
. The vertical and horizontal scrollbars will be displayed based on the following criteria:
- The vertical scrollbar appears when the total height of rows present in the gantt exceeds its element height.
- The horizontal scrollbar appears when the sum of columns width exceeds the grid pane size.
- The height and width are used to set the gantt height and width, respectively.
The default value for
height
andwidth
isauto
.
Set width and height
We can even set pixel values to width and height of gantt container using width and height properties.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { GanttModule } from '@syncfusion/ej2-angular-gantt'
import { SelectionService } from '@syncfusion/ej2-angular-gantt'
import { Component, ViewEncapsulation, OnInit } from '@angular/core';
import { Gantt } from '@syncfusion/ej2-gantt';
import { EditSettingsModel } from '@syncfusion/ej2-angular-gantt';
import { projectNewData } from './data';
@Component({
imports: [
GanttModule
],
providers: [SelectionService],
standalone: true,
selector: 'app-root',
template:
`<ejs-gantt id="ganttDefault" height="350px" width="600px" [dataSource]="data" [taskFields]="taskSettings"></ejs-gantt>`,
encapsulation: ViewEncapsulation.None
})
export class AppComponent{
// Data for Gantt
public data?: object[];
public taskSettings?: object;
public editSettings?: EditSettingsModel;
public ngOnInit(): void {
this.data = projectNewData;
this.taskSettings = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
child: 'subtasks'
};
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Responsive with the parent container
Specify the width and height as 100%
to make the gantt element fill its parent container.
Setting the height
to 100%
requires the gantt parent element to have explicit height. Also, the component will be responsive when the parent container is resized.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { GanttModule } from '@syncfusion/ej2-angular-gantt'
import { SelectionService } from '@syncfusion/ej2-angular-gantt'
import { Component, ViewEncapsulation, OnInit } from '@angular/core';
import { EditSettingsModel } from '@syncfusion/ej2-angular-gantt';
import { projectNewData } from './data';
@Component({
imports: [
GanttModule
],
providers: [SelectionService],
standalone: true,
selector: 'app-root',
template:
`<ejs-gantt id="ganttDefault" height="100%" width="100%" [dataSource]="data" [taskFields]="taskSettings"></ejs-gantt>`,
encapsulation: ViewEncapsulation.None
})
export class AppComponent{
// Data for Gantt
public data?: object[];
public taskSettings?: object;
public editSettings?: EditSettingsModel;
public ngOnInit(): void {
this.data = projectNewData;
this.taskSettings = {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
duration: 'Duration',
progress: 'Progress',
child: 'subtasks'
};
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));