|
| 1 | +<template> |
| 2 | + <div> |
| 3 | + <ejs-gantt ref="gantt" :dataSource="data" |
| 4 | + :taskFields="taskFields" |
| 5 | + :treeColumnIndex="1" |
| 6 | + :toolbar="toolbarOptions" |
| 7 | + :allowPdfExport="true" |
| 8 | + :allowExcelExport="true" |
| 9 | + :toolbarClick="toolbarBtnClk" |
| 10 | + :height="450"> |
| 11 | + <e-columns> |
| 12 | + <e-column field="TaskID" headerText="Task ID" width="120" textAlign="Right"></e-column> |
| 13 | + <e-column field="TaskName" headerText="Task Name" textAlign="Left" width="200"></e-column> |
| 14 | + <e-column field="StartDate" headerText="Start Date" textAlign="Right" format="dd/MM/yyyy" width="120"></e-column> |
| 15 | + <e-column field="Duration" headerText="Duration" textAlign="Right" width="120"></e-column> |
| 16 | + </e-columns> |
| 17 | + </ejs-gantt> |
| 18 | + </div> |
| 19 | +</template> |
| 20 | + |
| 21 | +<script> |
| 22 | +import {GanttComponent, ColumnsDirective, ColumnDirective, Toolbar, PdfExport, ExcelExport} from '@syncfusion/ej2-vue-gantt' |
| 23 | +import {projectNewData} from './data.js' |
| 24 | +export default{ |
| 25 | + name: 'App', |
| 26 | + components: { |
| 27 | + 'ejs-gantt': GanttComponent, |
| 28 | + 'e-columns': ColumnsDirective, |
| 29 | + 'e-column': ColumnDirective |
| 30 | + }, |
| 31 | + provide:{ |
| 32 | + gantt: [Toolbar, PdfExport, ExcelExport] |
| 33 | + }, |
| 34 | + methods:{ |
| 35 | + toolbarBtnClk(args){ |
| 36 | + let ganttObj = this.$refs.gantt.ej2Instances; |
| 37 | + if(args.item.text == 'Pdf export'){ |
| 38 | + ganttObj.pdfExport( |
| 39 | + { |
| 40 | + fileName: 'projectData.pdf', |
| 41 | + enableFooter: false, |
| 42 | + showPredecessorLines: false, |
| 43 | + theme: 'Fabric' |
| 44 | + } |
| 45 | + ) |
| 46 | + } else if(args.item.text == 'Excel export'){ |
| 47 | + ganttObj.excelExport({ |
| 48 | + fileName: 'projectData.xlsx', |
| 49 | + theme:{ |
| 50 | + header:{ fontColor:"#00008B"}, |
| 51 | + record:{ fontColor:"#C67878"} |
| 52 | + }, |
| 53 | + header:{ |
| 54 | + headerRows: 1, |
| 55 | + rows:[{ |
| 56 | + cells:[{ |
| 57 | + colSpan: 4, |
| 58 | + value: 'Project Time Tracking Report', |
| 59 | + style: {fontSize:20, hAlign:'Center'} |
| 60 | + }] |
| 61 | + }] |
| 62 | + }, |
| 63 | + footer:{ |
| 64 | + footerRows: 1, |
| 65 | + rows:[{ |
| 66 | + cells:[{ |
| 67 | + colSpan: 4, |
| 68 | + value: 'Visit Again!!!', |
| 69 | + style: {fontSize:18, hAlign:'Center'} |
| 70 | + }] |
| 71 | + }] |
| 72 | + } |
| 73 | + }) |
| 74 | + } else if(args.item.text == 'CSV export'){ |
| 75 | + ganttObj.csvExport() |
| 76 | + } |
| 77 | + } |
| 78 | + }, |
| 79 | + data(){ |
| 80 | + return{ |
| 81 | + data: projectNewData, |
| 82 | + toolbarOptions: ['PdfExport', 'ExcelExport', 'CsvExport'], |
| 83 | + taskFields:{ |
| 84 | + id: 'TaskID', |
| 85 | + name: 'TaskName', |
| 86 | + startDate: 'StartDate', |
| 87 | + endDate: 'EndDate', |
| 88 | + duration: 'Duration', |
| 89 | + progress: 'Progress', |
| 90 | + dependency: 'Predecessor', |
| 91 | + child: 'subtasks' |
| 92 | + }, |
| 93 | + } |
| 94 | + } |
| 95 | +} |
| 96 | +
|
| 97 | +</script> |
| 98 | + |
| 99 | +<style> |
| 100 | + @import url("https://cdn.syncfusion.com/ej2/material.css"); |
| 101 | +</style> |
| 102 | + |
0 commit comments