|
| 1 | +<template> |
| 2 | + <ejs-gantt ref="gantt" |
| 3 | + :dataSource="data" |
| 4 | + :taskFields="taskFields" |
| 5 | + :treeColumnIndex="1" |
| 6 | + :toolbar="toolbarOptions" |
| 7 | + :allowFiltering="true" |
| 8 | + :resources="resources" |
| 9 | + :resourceFields="resourceFields" |
| 10 | + v-on:toolbarClick="toolbarClick" |
| 11 | + :height="450" |
| 12 | + :rowHeight="60"> |
| 13 | + <e-columns> |
| 14 | + <e-column field="TaskID" headerText="Task ID" width="120" textAlign="Right"></e-column> |
| 15 | + <e-column field="TaskName" textAlign="Left" width="200" :headerTemplate="'headerTemplate'"></e-column> |
| 16 | + <e-column field="resources" :template="'resourceTemplate'" :headerTemplate="'headerTemplate2'"></e-column> |
| 17 | + <e-column field="StartDate" headerText="Start Date" textAlign="Right" format="dd/MM/yyyy" width="120"></e-column> |
| 18 | + <e-column field="Duration" headerText="Duration" textAlign="Right" width="120"></e-column> |
| 19 | + </e-columns> |
| 20 | + <template v-slot:headerTemplate> |
| 21 | + <div> |
| 22 | + <img src="https://ej2.syncfusion.com/vue/demos/source/gantt/images/taskname.png" height="20" width="20"/> Task Name |
| 23 | + </div> |
| 24 | + </template> |
| 25 | + <template v-slot:headerTemplate2> |
| 26 | + <div> |
| 27 | + <img src="https://ej2.syncfusion.com/vue/demos/source/gantt/images/resources.png" height="20" width="20"/> Resources |
| 28 | + </div> |
| 29 | + </template> |
| 30 | + <template v-slot:resourceTemplate="{data}"> |
| 31 | + <div v-if="data.ganttProperties.resourceNames"> |
| 32 | + <img :src="'https://ej2.syncfusion.com/vue/demos/source/gantt/images/' + data.ganttProperties.resourceNames + '.png'" |
| 33 | + height="40" width="40"/> |
| 34 | + </div> |
| 35 | + </template> |
| 36 | + </ejs-gantt> |
| 37 | +</template> |
| 38 | + |
| 39 | +<script> |
| 40 | +import {GanttComponent, ColumnsDirective, ColumnDirective, Toolbar, Filter} from '@syncfusion/ej2-vue-gantt' |
| 41 | +import {projectNewData, editingResources} from './data.js' |
| 42 | +export default { |
| 43 | + name: 'App', |
| 44 | + components: { |
| 45 | + 'ejs-gantt': GanttComponent, |
| 46 | + 'e-columns': ColumnsDirective, |
| 47 | + 'e-column': ColumnDirective |
| 48 | + }, |
| 49 | + provide:{ |
| 50 | + gantt: [Toolbar, Filter] |
| 51 | + }, |
| 52 | + methods:{ |
| 53 | + toolbarClick(args){ |
| 54 | + let ganttObj = this.$refs.gantt.ej2Instances; |
| 55 | + if(args.item.text === 'Quick Filter'){ |
| 56 | + ganttObj.filterByColumn('TaskName', 'startswith', 'Research'); |
| 57 | + } else{ |
| 58 | + ganttObj.clearFiltering(); |
| 59 | + } |
| 60 | + } |
| 61 | + }, |
| 62 | + data(){ |
| 63 | + return{ |
| 64 | + data: projectNewData, |
| 65 | + resources:editingResources, |
| 66 | + toolbarOptions:[{text: 'Quick Filter', tooltipText: 'Quick Filter', id: 'Quick Filter' }, |
| 67 | + { text: 'Clear Filter', tooltipText: 'Clear Filter', id: 'Clear Filter' }], |
| 68 | + resourceFields:{ |
| 69 | + id:'resourceId', |
| 70 | + name:'resourceName' |
| 71 | + }, |
| 72 | + taskFields:{ |
| 73 | + id: 'TaskID', |
| 74 | + name: 'TaskName', |
| 75 | + startDate: 'StartDate', |
| 76 | + endDate: 'EndDate', |
| 77 | + duration: 'Duration', |
| 78 | + progress: 'Progress', |
| 79 | + dependency: 'Predecessor', |
| 80 | + child: 'subtasks', |
| 81 | + resourceInfo: 'resources' |
| 82 | + }, |
| 83 | + } |
| 84 | + } |
| 85 | +} |
| 86 | +</script> |
| 87 | + |
| 88 | +<style> |
| 89 | + @import url("https://cdn.syncfusion.com/ej2/material.css"); |
| 90 | +</style> |
0 commit comments