|
| 1 | +<template> |
| 2 | + <ejs-treegrid :dataSource="data" childMapping="subtasks" |
| 3 | + :treeColumnIndex="1" :height='450'> |
| 4 | + <e-columns> |
| 5 | + <e-column field='ID' headerText='S.No' width='90' textAlign='Right'></e-column> |
| 6 | + <e-column field='Name' headerText='ShipMent Name' width='220'></e-column> |
| 7 | + <e-column field='category' headerText='Category' width='220'></e-column> |
| 8 | + <e-column field='unitPrice' headerText='Unit Price($)' format='c2' width='120' textAlign='Right'></e-column> |
| 9 | + <e-column field='price' headerText='Price($)' width='100' format='c' textAlign='Right'></e-column> |
| 10 | + </e-columns> |
| 11 | + <e-aggregates> |
| 12 | + <e-aggregate> |
| 13 | + <e-aggregate-columns :showChildSummary="false"> |
| 14 | + <e-aggregate-column field="price" type="Sum" :footerTemplate="footerSum"></e-aggregate-column> |
| 15 | + <e-aggregate-column field="unitPrice" type="Max" :footerTemplate="footerMax"></e-aggregate-column> |
| 16 | + </e-aggregate-columns> |
| 17 | + </e-aggregate> |
| 18 | + <e-aggregate> |
| 19 | + <e-aggregate-columns :showChildSummary="true"> |
| 20 | + <e-aggregate-column field="category" type="Custom" :footerTemplate="customFooter" :customAggregate="customAggregateFn"></e-aggregate-column> |
| 21 | + </e-aggregate-columns> |
| 22 | + </e-aggregate> |
| 23 | + </e-aggregates> |
| 24 | + </ejs-treegrid> |
| 25 | +</template> |
| 26 | +<script> |
| 27 | +import { TreeGridComponent, ColumnsDirective, ColumnDirective, Aggregate, AggregatesDirective, |
| 28 | + AggregateDirective, AggregateColumnsDirective, AggregateColumnDirective } from "@syncfusion/ej2-vue-treegrid"; |
| 29 | +import {summaryData} from './data.js'; |
| 30 | +import {createApp} from 'vue/dist/vue.esm-bundler'; |
| 31 | +import {getObject} from '@syncfusion/ej2-vue-grids'; |
| 32 | +const app = createApp(); |
| 33 | +var footerTemp = app.component("footerSum",{ |
| 34 | + template: "<span>Sum: {{data.Sum}}</span>", |
| 35 | + data: () => ({}) |
| 36 | +}) |
| 37 | +var footerTemp1 = app.component("footerMax",{ |
| 38 | + template: "<span>Maximum: {{data.Max}}</span>", |
| 39 | + data: () => ({}) |
| 40 | +}) |
| 41 | +var customAggregate = app.component("customFooter",{ |
| 42 | + template: "<b>Count of Frozen Seafood: {{data.Custom}}</b>", |
| 43 | + data: () => ({}) |
| 44 | +}) |
| 45 | +export default{ |
| 46 | + name: 'App', |
| 47 | + components: { |
| 48 | + 'ejs-treegrid': TreeGridComponent, |
| 49 | + 'e-columns': ColumnsDirective, |
| 50 | + 'e-column': ColumnDirective, |
| 51 | + 'e-aggregates': AggregatesDirective, |
| 52 | + 'e-aggregate': AggregateDirective, |
| 53 | + 'e-aggregate-columns': AggregateColumnsDirective, |
| 54 | + 'e-aggregate-column': AggregateColumnDirective |
| 55 | + }, |
| 56 | + data: () => { |
| 57 | + return { |
| 58 | + data: summaryData, |
| 59 | + footerMax(){ |
| 60 | + return{ |
| 61 | + template: footerTemp1 |
| 62 | + } |
| 63 | + }, |
| 64 | + customFooter(){ |
| 65 | + return{ |
| 66 | + template: customAggregate |
| 67 | + } |
| 68 | + }, |
| 69 | + footerSum(){ |
| 70 | + return{ |
| 71 | + template: footerTemp |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | + }, |
| 76 | + methods:{ |
| 77 | + customAggregateFn: function(data){ |
| 78 | + let sampleData = getObject('result', data); |
| 79 | + let countLength = 0; |
| 80 | + sampleData.filter((item) => { |
| 81 | + let data = getObject('category', item); |
| 82 | + if (data === 'Frozen seafood') { |
| 83 | + countLength++; |
| 84 | + } |
| 85 | + }); |
| 86 | + return countLength; |
| 87 | + } |
| 88 | + }, |
| 89 | + provide:{ |
| 90 | + treegrid: [Aggregate] |
| 91 | + } |
| 92 | +} |
| 93 | +</script> |
| 94 | + |
| 95 | +<style> |
| 96 | + @import "../node_modules/@syncfusion/ej2-base/styles/material.css"; |
| 97 | + @import "../node_modules/@syncfusion/ej2-buttons/styles/material.css"; |
| 98 | + @import "../node_modules/@syncfusion/ej2-calendars/styles/material.css"; |
| 99 | + @import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css"; |
| 100 | + @import "../node_modules/@syncfusion/ej2-inputs/styles/material.css"; |
| 101 | + @import "../node_modules/@syncfusion/ej2-navigations/styles/material.css"; |
| 102 | + @import "../node_modules/@syncfusion/ej2-popups/styles/material.css"; |
| 103 | + @import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css"; |
| 104 | + @import "../node_modules/@syncfusion/ej2-vue-grids/styles/material.css"; |
| 105 | + @import "../node_modules/@syncfusion/ej2-vue-treegrid/styles/material.css"; |
| 106 | +
|
| 107 | + .btn{ |
| 108 | + margin: 1%; |
| 109 | + } |
| 110 | +
|
| 111 | + .e-image { |
| 112 | + height: 13px; |
| 113 | + width: 14px; |
| 114 | + vertical-align: middle; |
| 115 | + } |
| 116 | +</style> |
0 commit comments