var obj = [
{ "CalcField": 0, "EmployeeID": 1, "LastName": "Davolio", "FirstName": "Nancy", "Title": "Sales Representative", "City": "Seattle", "Country": "USA" },
{ "CalcField": 0, "EmployeeID": 2, "LastName": "Fuller", "FirstName": "Andrew", "Title": "Vice President, Sales", "City": "Tacoma", "Country": "USA" },
{ "CalcField": 0, "EmployeeID": 3, "LastName": "Leverling", "FirstName": "Janet", "Title": "Sales Representative", "City": "Kirkland", "Country": "USA" },
{ "CalcField": 0, "EmployeeID": 4, "LastName": "Peacock", "FirstName": "Margaret", "Title": "Sales Representative", "City": "Redmond", "Country": "USA" },
];
|
<div id="Grid" ej-grid e-datasource="data" e-allowsorting="true" e-allowpaging="true"
e-showsummary="true" e-summaryrows="summaryRows" e-querycellinfo="querycell">
<div e-toolbarsetting-showtoolbar=true>
</div>
<div e-columns>
<div e-column e-field="EmployeeID" e-headertext="Employee ID" e-textalign="right" e-width="90"></div>
<div e-column e-field="LastName" e-headertext="Last Name" e-textalign="left" e-width="90"></div>
<div e-column e-field="FirstName" e-headertext="FirstName" e-textalign="left" e-width="90"></div>
<div e-column e-field="Title" e-headertext="Title" e-textalign="left" e-width="90"></div>
<div e-column e-field="City" e-headertext="City" e-textalign="left" e-width="90"></div>
<div e-column e-field="Country" e-headertext="Country" e-textalign="left" e-width="90"></div>
<div e-column e-field="CalcField" e-headertext="Calculated field"
e-textalign="left" e-width="90"></div>
</div>
</div>
$scope.querycell = function (args) {
if (args.column.field == "CalcField") {
args.data["CalcField"] = args.data["EmployeeID"] * 30 - args.data["EmployeeID"]; //set the datasource value
$(args.cell).html(args.data["CalcField"]); //set the element values
}
} |
$scope.summaryRows = [{
title: 'Summary',
summaryColumns: [
{
summaryType: ej.Grid.SummaryType.Sum,
dataMember: 'CalcField',
displayColumn: "CalcField",
format: "{0:C0}"
},
{
summaryType: ej.Grid.SummaryType.Custom,
customSummaryValue: $scope.fnc,
displayColumn: "Country",
format: "{0:C0}"
}
]
}]; |
<div id="Grid" ej-grid e-datasource="data" e-allowsorting="true" e-allowpaging="true"
e-showsummary="true" e-summaryrows="summaryRows" e-querycellinfo="querycell" e-databound="databound">
<div e-toolbarsetting-showtoolbar=true>
</div>
. . .
</div>
$scope.databound = function (args) {
this.initialRender = false; // use this code when using the 13.2.0.29 version & no need this line for latest version
this.refreshContent(); //refresh the Grid contents
}; |