dhtmlxGantt와 ASP.NET Core 사용하기
이 가이드는 서버 측에서 ASP.NET Core를 사용하여 Gantt 차트를 설정하는 과정을 안내합니다.
다른 서버사이드 플랫폼에 대한 튜토리얼도 제공됩니다:
- dhtmlxGantt와 ASP.NET MVC
- dhtmlxGantt와 Node.js 연동하기
- dhtmlxGantt와 Python
- dhtmlxGantt와 PHP: Laravel 연동
- dhtmlxGantt와 PHP:Slim 연동하기
- dhtmlxGantt와 Salesforce LWC 연동하기
- dhtmlxGantt와 Ruby on Rails 연동하기
데이터베이스 관리를 위해 Entity Framework Core를 사용합니다. 본 프로젝트는 Visual Studio 2022를 사용하여 개발되었습니다.
노트
전체 소스 코드는 GitHub에서 확인할 수 있습니다.
1단계. 프로젝트 생성
Visual Studio 2022를 시작한 후 Create a new project를 선택하여 새 프로젝트를 만듭니다.

이후 "ASP.NET Core Web App"을 선택하고 프로젝트 이름을 DHX.Gantt로 지정합니다.



프로젝트가 생성되면 Gantt에 필요한 마크업과 스크립트를 추가할 수 있습니다.
2단계. Gantt 마크업 및 JS 추가
wwwroot로 이동하여 index.html이라는 새 파일을 생성합니다.


이 파일에서 간단한 페이지를 작성하여 gantt 차트를 표시합니다.
이 예제에서는 gantt 파일이 CDN에서 로드됩니다. Professional 버전을 사용하는 경우, 직접 gantt 파일을 프로젝트에 추가해야 합니다.
index.html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width="device-width"" />
<title>Index</title>
<link href="https://cdn.dhtmlx.com/gantt/edge/dhtmlxgantt.css"
rel="stylesheet" type="text/css" />
<script src="https://cdn.dhtmlx.com/gantt/edge/dhtmlxgantt.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function(event) {
// specifying the date format
gantt.config.date_format = "%Y-%m-%d %H:%i";
// initializing gantt
gantt.init("gantt_here");
// initiating data loading
gantt.load("/api/data");
// initializing dataProcessor
var dp = new gantt.dataProcessor("/api/");
// and attaching it to gantt
dp.init(gantt);
// setting the REST mode for dataProcessor
dp.setTransactionMode("REST");
});
</script>
</head>
<body>
<div id="gantt_here" style={{width: '100%', height: '100vh'}}></div>
</body>
</html>
페이지가 로드되면 gantt 차트가 초기화되고 gantt.load()를 통해 바로 데이터 로딩이 시작됩니다. dataProcessor도 설정되어 있어, 차트에서 사용자가 변경한 내용이 서버에 저장됩니다. 아직 백엔드가 준비되지 않았기 때문에 전체 기능은 구현 후 확인할 수 있습니다.