Responsive columns in Angular Gantt component

4 Jan 20243 minutes to read

You can toggle the column visibility based on media queries, which are defined in the hideAtMedia. The hideAtMedia accepts valid Media Queries.

import { Component, ViewEncapsulation, OnInit } from '@angular/core';
import { GanttData } from './data';

  selector: 'app-root',
    `<ejs-gantt id="ganttDefault" height="430px" [dataSource]="data"  [taskFields]="taskSettings" [treeColumnIndex]='1' [splitterSettings] = "splitterSettings" [allowResizing] = 'true'>          
            <e-column field='TaskID' headerText='Task ID' textAlign='Right' width=90 ></e-column>
            // column hides when browser screen width lessthan 700px;
            <e-column field='TaskName' headerText='Task Name' textAlign='Left' width=290 hideAtMedia='(min-width: 700px)'></e-column>
            <e-column field='StartDate' headerText='Start Date' textAlign='Right' width=120 ></e-column>
            // column shows when browser screen width lessthan or equalto 500px;
            <e-column field='Duration' headerText='Duration' textAlign='Right' width=90 hideAtMedia='(max-width: 500px)'></e-column>
            <e-column field='Progress' headerText='Progress' textAlign='Right' width=150></e-column>
  encapsulation: ViewEncapsulation.None
export class AppComponent {
  // Data for Gantt
  public data?: object[];
  public taskSettings?: object;
  public splitterSettings?: object;
  public ngOnInit(): void { = GanttData;
    this.taskSettings = {
      id: 'TaskID',
      name: 'TaskName',
      startDate: 'StartDate',
      duration: 'Duration',
      progress: 'Progress',
      child: 'subtasks'
    this.splitterSettings = {
      position: '75%'
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { GanttModule } from '@syncfusion/ej2-angular-gantt';

 * Module
    imports: [
        BrowserModule, GanttModule
    declarations: [AppComponent],
    bootstrap: [AppComponent]
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

import 'zone.js';