forked from syncfusion/ej2-vue-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheader-template.vue
175 lines (169 loc) · 5.98 KB
/
header-template.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<template>
<div class="col-lg-12 control-section">
<div>
<ejs-gantt ref='gantt' id="HeaderTemplate"
:dataSource= "data"
:height = "height"
:highlightWeekends= 'true'
:taskFields= "taskFields"
:labelSettings= "labelSettings"
:splitterSettings= "splitterSettings"
:resourceFields= "resourceFields"
:resources= "resources"
:projectStartDate= "projectStartDate"
:projectEndDate= "projectEndDate">
<e-columns>
<e-column field='TaskName' width='250' :headerTemplate='nametemplate'></e-column>
<e-column field='StartDate' width='150' :headerTemplate='datetemplate'></e-column>
<e-column field='resources' :headerTemplate='resourcetemplate'></e-column>
<e-column field='Duration' :headerTemplate='durationtemplate'></e-column>
<e-column field='Progress' :headerTemplate='progresstemplate'></e-column>
</e-columns>
</ejs-gantt>
</div>
<div id="action-description">
<p>This sample demonstrates the Gantt header template feature. In this sample, custom icons have been shown in the column headers.</p>
</div>
<div id="description">
<p>
The Gantt provides a way to define a custom element in header element. The <code>Columns > headerTemplate</code> property accepts accepts a vue component,
which will be used as the template for the header cell.
</p>
<p>In this demo, we have rendered the customized template for all column headers.</p>
<p>More information about the header template can be found in documentation section.</p>
</div>
</div>
</template>
<!-- custom code start -->
<style scoped>
/deep/ .e-image {
margin-right: 8px;
}
</style>
<!-- custom code end -->
<script lang="ts">
import Vue from "vue";
import { GanttPlugin, Selection } from "@syncfusion/ej2-vue-gantt";
import { templateData, editingResources } from './data-source';
Vue.use(GanttPlugin);
export default Vue.extend({
data: () => {
return {
data: templateData,
height: '450px',
taskFields: {
id: 'TaskID',
name: 'TaskName',
startDate: 'StartDate',
endDate: 'EndDate',
duration: 'Duration',
progress: 'Progress',
resourceInfo: 'resources',
dependency: 'Predecessor',
child: 'subtasks'
},
resourceFields: {
id: 'resourceId',
name: 'resourceName'
},
resources: editingResources,
labelSettings: {
leftLabel: 'TaskName'
},
splitterSettings:{
columnIndex: 4
},
projectStartDate: new Date('03/24/2019'),
projectEndDate: new Date('07/06/2019'),
nametemplate: function () {
return { template : Vue.component('nametemplate',{
template: `<div>
<img :src="image" width="20px" height="20px" class="e-image"/> Task Name
</div>`,
data: function() {
return {
data: {}
}
},
computed: {
image: function() {
return "https://ej2.syncfusion.com/vue/demos/source/gantt/images/taskname.png";
}
}
})}
},
datetemplate: function () {
return { template : Vue.component('datetemplate',{
template: `<div>
<img :src="image" width="20px" height="20px" class="e-image"/> Start Date
</div>`,
data: function() {
return {
data: {}
}
},
computed: {
image: function() {
return "https://ej2.syncfusion.com/vue/demos/source/gantt/images/startdate.png";
}
}
})}
},
resourcetemplate: function () {
return { template : Vue.component('resourcetemplate',{
template: `<div>
<img :src="image" width="20px" height="20px" class="e-image"/> Resources
</div>`,
data: function() {
return {
data: {}
}
},
computed: {
image: function() {
return "https://ej2.syncfusion.com/vue/demos/source/gantt/images/resources.png";
}
}
})}
},
durationtemplate: function () {
return { template : Vue.component('durationtemplate',{
template: `<div>
<img :src="image" width="20px" height="20px" class="e-image"/> Duration
</div>`,
data: function() {
return {
data: {}
}
},
computed: {
image: function() {
return "https://ej2.syncfusion.com/vue/demos/source/gantt/images/duration.png";
}
}
})}
},
progresstemplate: function () {
return { template : Vue.component('progresstemplate',{
template: `<div>
<img :src="image" width="20px" height="20px" class="e-image"/> Progress
</div>`,
data: function() {
return {
data: {}
}
},
computed: {
image: function() {
return "https://ej2.syncfusion.com/vue/demos/source/gantt/images/progress.png" ;
}
}
})}
}
};
},
provide : {
gantt: [Selection],
}
});
</script>