<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ZingGrid: Simple Grid</title>
<script nonce="undefined" src="https://cdn.zinggrid.com/zinggrid.min.js"></script>
<style>
.zg-body {
background-color: #e6e6e6;
}
zing-grid[loading] {
height: 213px;
}
</style>
</head>
<body class="zg-body">
<h3>Average Calculated Grid with Custom Renderer</h3>
<p>Here is a complete grid with the average of each column calculated with a custom renderer applied:</p>
<zing-grid data='[
{ "id": "383", "first": "Maria", "last": "John", "test1": 0.92, "test2": 0.97, "test3": 0.84},
{ "id": "384", "first": "David", "last": "Smith", "test1": 0.86, "test2": 0.79, "test3": 0.86 },
{ "id": "385", "first": "Felicity", "last": "Snow", "test1": 0.84, "test2": 0.66, "test3": 0.76 }
]'>
<zg-colgroup>
<zg-column index="first"></zg-column>
<zg-column index="last"></zg-column>
<zg-column index="test1"></zg-column>
<zg-column index="test2"></zg-column>
<zg-column index="test3"></zg-column>
<zg-column type="aggregate" type-aggregate-value="avg" renderer="aggregateRenderer"></zg-column>
</zg-colgroup>
</zing-grid>
<script>
ZingGrid.setLicense(['26ccbfec16b8be9ee98c7d57bee6e498']);
var aggregateRenderer = function(recordData, aggregateData, aggregateValue) {
console.log('Record Data: ', recordData);
console.log('Aggregate Data: ', aggregateData);
console.log('Aggregate Value: ', aggregateValue);
return `The average of ${aggregateData.join(', ')} for ${recordData.first} ${recordData.last} is ${aggregateValue}.`;
};
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ZingGrid: Simple Grid</title>
<script src="https://cdn.zinggrid.com/zinggrid.min.js"></script>
</head>
<body class="zg-body">
<h3>Average Calculated Grid with Custom Renderer</h3>
<p>Here is a complete grid with the average of each column calculated with a custom renderer applied:</p>
<zing-grid data='[
{ "id": "383", "first": "Maria", "last": "John", "test1": 0.92, "test2": 0.97, "test3": 0.84},
{ "id": "384", "first": "David", "last": "Smith", "test1": 0.86, "test2": 0.79, "test3": 0.86 },
{ "id": "385", "first": "Felicity", "last": "Snow", "test1": 0.84, "test2": 0.66, "test3": 0.76 }
]'>
<zg-colgroup>
<zg-column index="first"></zg-column>
<zg-column index="last"></zg-column>
<zg-column index="test1"></zg-column>
<zg-column index="test2"></zg-column>
<zg-column index="test3"></zg-column>
<zg-column type="aggregate" type-aggregate-value="avg" renderer="aggregateRenderer"></zg-column>
</zg-colgroup>
</zing-grid>
</body>
</html>
.zg-body {
background-color: #e6e6e6;
}
var aggregateRenderer = function(recordData, aggregateData, aggregateValue) {
console.log('Record Data: ', recordData);
console.log('Aggregate Data: ', aggregateData);
console.log('Aggregate Value: ', aggregateValue);
return `The average of ${aggregateData.join(', ')} for ${recordData.first} ${recordData.last} is ${aggregateValue}.`;
};