Summary template
Dear all,
is it possible to template summary based on sum number?
I want to have red summary if number is below 80, orange if between 80 and 100 and green if over 100.
I want style summary cell or to the whole row.
Regards, Egi
SIGN IN To post a reply.
3 Replies
SS
Seeni Sakthi Kumar Seeni Raj
Syncfusion Team
December 1, 2016 02:55 PM UTC
Hi Egi,
You can template property of the summaryColumns to format/customize the corresponding summary cells/group summary cells. In the following code example, we have use the jsrender helper functions along the template property to format the Summary cells.
|
<div id="Grid"></div>
<script type="text/javascript">
function format(value, proxy) {
var val = ej.parseFloat(value);
if (val < 80)
return '<span style="color: red">' + value + '</span>';
if (val >= 80 && val <= 100)
return '<span style="color: orange">' + value + '</span>';
if (val > 100)
return '<span style="color: green">' + value + '</span>';
}
$(function () {
var helpers = { formatting: format };//helpers
$.views.helpers(helpers);
$("#Grid").ejGrid({
dataSource: window.gridData,
allowPaging: true,
allowSorting: true,
showSummary: true,
allowGrouping: true,
summaryRows: [
{
title: "Sum",
summaryColumns: [{
summaryType: ej.Grid.SummaryType.Sum,
template: "{{:~formatting(#data['summaryValue'])}}",
displayColumn: "Freight", dataMember: "Freight",
format: "{0:C2}"
}]
}
],
columns: [
. ..
{ field: "Freight", format: "{0:C}" }
]
});
});
</script> |
We have also prepared a sample that can be referred from the following jsPlayground.
Refer to the following API reference section.
Regards,
Seeni Sakthi Kumar S.
EŽ
Egi Žaberl
December 6, 2016 09:16 AM UTC
That is what i want. Thank you for your answer/sample!
Regards, Egi
Regards, Egi
SS
Seeni Sakthi Kumar Seeni Raj
Syncfusion Team
December 8, 2016 04:15 AM UTC
Hi Egi,
We are happy to hear that your query has been resolved. If you require further assistance on this, please get back to us.
Regards,
Seeni Sakthi Kumar S.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
EŽ Egi Žaberl
- Nov 30, 2016 10:47 AM UTC
- Dec 8, 2016 04:15 AM UTC