How to format cell font color when a AMOUNT value is greater than 50 then green else red conditonally when exported to excel as CSV.
$scope.gridOptions = {
enableColumnResizing: true,
enableFiltering: false,
enablePagination: true,
enablePaginationControls: true,
paginationPageSizes: [50, 100, 250],
paginationPageSize: 50,
enableVerticalScrollbar: 1,
enableHorizontalScrollbar: 1,
columnDefs: [
{ name: "RecordID", displayName: "Record ID", cellClass: 'numberAlign', cellTooltip: true, headerTooltip: true, enableColumnMenu: false, width: '10%', enableSorting: true },*/
{ name: "AMOUNT", displayName: "Amount", type: "number", headerTooltip: 'Amount', cellClass: 'numberAlign', cellFilter: 'currency:"$" : 2', width: '10%', enableColumnMenu: false, enableSorting: true, cellTemplate: '<div class="ui-grid-cell-contents"><span ng-if="row.entity.SOURCETYPE != \'Distribution of Funds\' && row.entity.AMOUNT < 0" style="color:red;">{{row.entity.AMOUNT | currency}}</span><span ng-if="row.entity.SOURCETYPE != \'Distribution of Funds\' && row.entity.AMOUNT >= 0">{{row.entity.AMOUNT | currency}}</span><span ng-if="row.entity.SOURCETYPE === \'Distribution of Funds\'" style="color:green;">{{row.entity.AMOUNT | currency}}</span></div>' },
{ name: "STATUS", displayName: "Status", cellClass: 'numberAlign', width: '7%', cellTooltip: true, headerTooltip: true, enableColumnMenu: false, enableSorting: false },
],
exporterFieldCallback: function (grid, row, col, value) {
col.colDef.width = 500
if (col.name === "AMOUNT") {
if (angular.isDefined(value) && value != null) {
value = '$' + value.toFixed(2);
}
}
// Below one is export for branch specific page. wut_details_branch
return value;
},
onRegisterApi: function (gridApi) {
$scope.gridApi = gridApi;
}
};