I use uigrid in my angulrjs project:
Here is content to display:
$scope.arr = [{id:'124',name:'Max', IsMale:'true'},
{id:'589',name:'Anna', IsMale:'false'},
{id:'45',name:'Donna', IsMale:'false'},
{id:'567',name:'Mark', IsMale:'true'}];
Here is UI-GRID defenition:
$scope.gridOptions = {
enableColumnMenus: false,
enableSorting: true,
enableFiltering: false,
enableToopTip: true,
enableHorizontalScrollbar: 0,
onRegisterApi: function (gridApi) {
gridApi = gridApi
}
}
$scope.gridOptions.columnDefs = [
{ name: 'Name ', field: 'name', cellTooltip: true, headerTooltip: true },
{ name: 'Id ', field: 'id', cellTooltip: true, headerTooltip: true },
{ name: 'IsMail ', field: 'IsMale', cellTooltip: true, headerTooltip: true }];
$scope.gridOptions.data = $scope.arr;
Here is template:
<div id="grid1" ui-grid="gridOptions" class="grid"></div>
Here is working plunker.
I want to change displayed content of the IsMal
field in ui-grid where the filed shows "true" I need to display "Yes" and where is false I need to display "No".
Any ides how can I change the displayed content in ui-grid field?
I changed your $scope.arr so your isMale is actually a boolean type.
$scope.arr = [{id:'124',name:'Max', IsMale:true},
{id:'589',name:'Anna', IsMale:false},
{id:'45',name:'Donna', IsMale:false},
{id:'567',name:'Mark', IsMale:true}];
And then I added a cellTemplate to your gridOptions.
$scope.gridOptions.columnDefs = [
{ name: 'IsMail ', field: 'IsMail', cellTooltip: true, headerTooltip: true, cellTemplate: '<div><p ng-if="COL_FIELD">YES</p><p ng-if="!COL_FIELD">NO</p></div>' }];