forked from syncfusion/ej2-vue-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexporting.vue
120 lines (117 loc) · 4.3 KB
/
exporting.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<template>
<div>
<div class="control-section">
<div class="content-wrapper">
<ejs-gantt ref='gantt' id="GanttExport"
:dataSource= "data"
:dateFormat= "dateFormat"
:taskFields= "taskFields"
:toolbar= "toolbar"
:allowSelection= "true"
:allowExcelExport= "true"
:gridLines= "gridLines"
:height= "height"
:treeColumnIndex= "1"
:toolbarClick= "toolbarClick"
:resourceFields= "resourceFields"
:resources= "resources"
:highlightWeekends= "true"
:timelineSettings= "timelineSettings"
:labelSettings= "labelSettings"
:projectStartDate= "projectStartDate"
:projectEndDate= "projectEndDate"
:columns = "columns"
:allowPdfExport = "true"
:splitterSettings= "splitterSettings">
</ejs-gantt>
</div>
</div>
<div id="action-description">
<p>This sample demonstrates client-side exporting of the Gantt, which allows you to export Gantt data to Excel, PDF and CSV formats. Using the Gantt toolbar buttons, you can export Gantt data to the desired format. </p>
</div>
<div id="description">
<p>Gantt supports client-side exporting, which allows you to export its data to the Excel, PDF and CSV formats. </p>
<p>In this demo, we have defined actions in the <code>toolbarClick</code> event to export the Gantt data using the <code>excelExport</code>, <code>pdfExport</code> and <code>csvExport</code> methods.</p>
<p style="font-weight: 500">Injecting Module:</p>
<p>To use Excel and CSV export features, inject the <code>ExcelExport</code> module using the <code>Gantt.Inject(ExcelExport)</code> method. </p>
<p>To use PDF feature, inject the <code>PdfExport</code> module using the <code>Gantt.Inject(PdfExport)</code> method. </p>
</div>
</div>
</template>
<script>
import Vue from "vue";
import { GanttPlugin, Selection, Toolbar, ExcelExport, PdfExport } from "@syncfusion/ej2-vue-gantt";
import { editingData, editingResources } from './data-source';
Vue.use(GanttPlugin);
export default Vue.extend({
data: function() {
return{
data: editingData,
dateFormat: 'MMM dd, y',
taskFields: {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
dependency: 'Predecessor',
child: 'subtasks',
resourceInfo: 'resources'
},
toolbar: ['ExcelExport', 'CsvExport', 'PdfExport'],
gridLines: 'Both',
height: '450px',
resourceFields: {
id: 'resourceId',
name: 'resourceName'
},
resources: editingResources,
timelineSettings: {
topTier: {
unit: 'Week',
format: 'MMM dd, y',
},
bottomTier: {
unit: 'Day',
},
},
labelSettings: {
leftLabel: 'TaskName',
rightLabel: 'resources'
},
projectStartDate: new Date('03/25/2019'),
projectEndDate: new Date('07/28/2019'),
columns: [
{ field: 'TaskID'},
{ field: 'TaskName', width: '250' },
{ field: 'StartDate' },
{ field: 'EndDate' },
{ field: 'Duration' },
{ field: 'Predecessor' },
{ field: 'resources' },
{ field: 'Progress' }
],
splitterSettings: {
columnIndex: 2
}
};
},
provide: {
gantt: [Selection, Toolbar, ExcelExport, PdfExport]
},
methods:{
toolbarClick:function (args) {
if (args.item.id === 'GanttExport_excelexport') {
this.$refs.gantt.ej2Instances.excelExport();
}
else if (args.item.id === 'GanttExport_csvexport') {
this.$refs.gantt.ej2Instances.csvExport();
}
else if (args.item.id === 'GanttExport_pdfexport') {
this.$refs.gantt.ej2Instances.pdfExport();
}
}
}
});
</script>