I am intending to call same function for all columns. I tried many different way to call function. None did work. I am sure i did something silly. If someone can correct me.
$scope.gridOptions = {
enableSorting: true,
columnDefs: [
{ field: 'name',
//cellClass: howCanIhaveCommonFunction()
},
{ field: 'company',
//cellClass: howCanIhaveCommonFunction()
}
]
};
// below function this would be common for all columns
var howCanIhaveCommonFunction = function(grid, row, col, rowRenderIndex, colRenderIndex)
{
if (grid.getCellValue(row,col) === 'Velity' || grid.getCellValue(row,col) === 'Beryl Rice' ) {
return 'blue';
}
return 'red';
}
http://plnkr.co/edit/4yjVbhmfR47cf7FGfyFk?p=preview
Yes it is a simple mistake, instead of saying just the function name, you are invoking it without any arguments.
$scope.gridOptions = {
enableSorting: true,
columnDefs: [
{ field: 'name',
cellClass: howCanIhaveCommonFunction
},
{ field: 'company',
cellClass: howCanIhaveCommonFunction
}
]
You just made all the arguments null by having those (), just pass the function name and ui-grid will invoke it with right arguments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With