new Vue({
el: '#app',
template: `
<div id="app">
<ejs-grid id="Grid" ref="grid" :dataSource="data" height='315px' :showColumnMenu="true"
:columnMenuItems="columnMenuItems"
:columnMenuClick="columnMenuClick">
<e-columns>
....
</e-columns>
</ejs-grid>
</div>
`,
data() {
return {
data: data,
columnMenuItems: [{text:'Aggregate Sum', id:'aggsum'},
{text:'Remove Aggregate', id:'aggremove'}],
};
},
provide: {
grid: [Edit,Toolbar,ContextMenu, Aggregate, ColumnMenu]
}
methods: {
columnMenuClick: function(args) {
if(args.item.id === 'aggsum'){
this.$refs.grid.aggregates = [{
columns: [{
field: 'Freight', type: 'Sum', format: 'c2'
}]
}];
}
if(args.item.id === 'aggremove') {
this.$refs.grid.aggregates = [];
}
}
}
});
|
this.$refs.grid.aggregates = [{
columns: [{
field: 'Freight', type: 'Sum', format: 'c2',
groupFooterTemplate: function() {
return {
template: Vue.component('sumTemplate', {
template: `<span>Sum: {{data.Sum}}</span>`,
data: function () {
return {
data: {
data: {}
}
};
}
})
}
}
}]
}]
|
<template>
<div id="app">
<ejs-grid ref='grid' :load='load' :aggregates="aggregates" >
......
</ejs-grid>
</div>
</template>
<script>
export default {
data() {
return {
data: data,
aggregates: [
{
columns: [
{ type: "Count", field: "groupTitle", groupFooterTemplate: 'countTemplate' },
{ type: "Custom", columnName: "status", customAggregate: "customAggregateStatus", groupFooterTemplate: 'statusTemplate' },
{ type: "Sum", field: "numbers", groupFooterTemplate: 'sumTemplate' }
]
}
],
...
};
},
provide: {
},
methods: {
columnMenuClick(args) {
if (args.item.parentObj.id === 'aggregate') {
this.aggregates = [{
columns: [{
field: 'numbers', type: args.item.text
}]
}];
}
},
...
}
}
</script> |