<style>
</style> |
// Grid’s dataBound event function
dataBound() {
// Aggregate module
var footerAggregate = this.$refs.gridObj.ej2Instances.aggregateModule.footerRenderer;
// Condition is checked with aggregate value which will be stored like – [“Column Field – aggregate type”]
if (footerAggregate.aggregates.aggregates["Freight - sum"] > 200) {
// Class is added to the aggregate cell
footerAggregate.contentTable.querySelectorAll('.e-templatecell')[0].classList.add('above-200');
}
// Condition is checked with aggregate value which will be stored like – [“Column Field – aggregate type”]
if (footerAggregate.aggregates.aggregates["Freight - max"] < 150) {
// Class is added to the aggregate cell
footerAggregate.contentTable.querySelectorAll('.e-templatecell')[1].classList.add('below-150');
}
}
<style>
// Aggregate cell styles set based on added class
.above-200 {
color: #8f8f1d !important;
}
.below-150 {
color: red !important;
}
</style> |
<e-column type='checkbox' headerText='Bool' width=120></e-column> |
<e-column field='fieldname' headerText='bool' textAlign='center' displayAsCheckBox='true'></e-column> |
<ejs-grid :dataSource="data" ref='gridObj' :dataBound='dataBound' :allowPaging="true" :queryCellInfo='matrixColoring' :allowSorting="true" :pageSettings='pageSettings'>
<e-aggregates>
<e-aggregate>
<e-columns>
<e-column type="Sum" field="Freight" :footerTemplate='footerSum'></e-column>
</e-columns>
</e-aggregate>
<e-aggregate>
<e-columns>
<e-column type="Max" field="Freight" :footerTemplate='footerMax'></e-column>
</e-columns>
</e-aggregate>
</e-aggregates>
</ejs-grid>
export default {
name: 'app',
data() {
return {
footerSum: function () {
return {
template: Vue.component('sumTemplate', {
template: `<span class='sum-aggregate'>Sum: {{data.Sum}}</span>`,
data() { return { data: {} }; }
})
}
},
footerMax: function () {
return {
template: Vue.component('maxTemplate', {
template: `<span class='max-aggregate'>Max: {{data.Max}}</span>`,
data() { return { data: {} }; }
})
}
}
};
},
methods: {
dataBound() {
var footerAggregate = this.$refs.gridObj.ej2Instances.aggregateModule.footerRenderer;
if (footerAggregate.aggregates.aggregates["Freight - sum"] > 200) {
footerAggregate.contentTable.querySelector('.sum-aggregate').closest('.e-templatecell').classList.add('above-200');
}
if (footerAggregate.aggregates.aggregates["Freight - max"] < 150) {
footerAggregate.contentTable.querySelector('.max-aggregate').closest('.e-templatecell').classList.add('below-150');
}
}
},
provide: {
grid: [Aggregate, Page, Sort]
}
} |
<e-column type="Custom" columnName="Y" format='C2' :customAggregate="cpAggregate" ></e-column> |
dataBound() {
var footerAggregate = this.$refs.gridObj.ej2Instances.aggregateModule.footerRenderer;
var aggregateCells = [];
// The template cell element of the aggregate cells are returned from the custom-class added to them through footer template
footerAggregate.contentTable.querySelectorAll('.sum-aggregate').forEach(x => aggregateCells.push(x.closest('.e-templatecell')));
// The id’s of the required column are retrieved using their field names
var col1ID = this.$refs.gridObj.getColumnByField('Freight1').uid;
var col3ID = this.$refs.gridObj.getColumnByField('Freight3').uid;
var colorAggregates = [];
// The template cell’s ‘e-mappinguid’ is compared with the column’s id and based on that the cell can be customized
aggregateCells.forEach(x => (x.getAttribute('e-mappinguid') === col1ID || x.getAttribute('e-mappinguid') === col3ID) ? x.classList.add('custom-cell-color') : [])
} |
<style>
@import '../../node_modules/@syncfusion/ej2-base/styles/bootstrap4.css';
@import '../../node_modules/@syncfusion/ej2-buttons/styles/bootstrap4.css';
@import '../../node_modules/@syncfusion/ej2-calendars/styles/bootstrap4.css';
@import '../../node_modules/@syncfusion/ej2-dropdowns/styles/bootstrap4.css';
@import '../../node_modules/@syncfusion/ej2-inputs/styles/bootstrap4.css';
@import '../../node_modules/@syncfusion/ej2-navigations/styles/bootstrap4.css';
@import '../../node_modules/@syncfusion/ej2-popups/styles/bootstrap4.css';
@import '../../node_modules/@syncfusion/ej2-splitbuttons/styles/bootstrap4.css';
@import "../../node_modules/@syncfusion/ej2-vue-grids/styles/bootstrap4.css";
</style> |
<e-column type="Custom" field="Y" columnName="Y" format='C2' :customAggregate="cpAggregate"><e-column> |
@import '../../node_modules/@syncfusion/ej2-base/styles/bootstrap4.css';
@import "../../node_modules/@syncfusion/ej2-vue-grids/styles/bootstrap4.css"; |
export default {
name: 'app',
data() {
return {
.
.
footerTemp: function () {
return {
template: Vue.component('footerTemplate', {
template: `<span class='custom-aggregate'>{{data.Custom}}</span>`,
data() { return { data: {} }; }
})
}
}
};
},
methods: {
.
.
dataBound() {
var footerAggregate = this.$refs.gridObj.ej2Instances.aggregateModule.footerRenderer;
var customAggregate = footerAggregate.contentTable.querySelector('.custom-aggregate');
if (customAggregate) {
var customAggregateVal = customAggregate.innerText;
(Number(customAggregateVal) > 200) ? customAggregate.classList.add('custom-cell-color') : [];
}
}
}, |
<style>
</style> |