ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

Adding an icon to CellTemplate

Open redapplewithleaves opened this issue 11 years ago • 4 comments

I'm trying to have a table that has the cell template to display icons and the column information: $scope.genderTemplate = '<i class="fa fa-{{COL_FIELD}}"></i>{{COL_FIELD}}' ;

Accessed by:

    $scope.gridOptions.columnDefs = [
         { name: 'name' },
         { name: 'gender', cellTemplate:genderTemplate},
         { name: 'ShowScope',
             cellTemplate:'<button class="btn primary" ng-click="grid.appScope.showMe()">Click Me</button>' }
       ];

But the table does not show up.

Here is the plnkr: http://plnkr.co/edit/ufMcRpXN2y0mXmZdK17V?p=preview

redapplewithleaves avatar Apr 09 '15 16:04 redapplewithleaves

You hadn't saved your plunker, so I'm assuming the problem was probably a typo somewhere in the plunker.

Here's an updated one with the code you suggest above, and it seems to work fine: http://plnkr.co/edit/MaSuKSnk7HvdjK4DERlR?p=preview

PaulL1 avatar Apr 09 '15 22:04 PaulL1

It must have been a typo...

Is it possible to have the icon only show based on the content of COL_FIELD? For example, only show when it is a female?

cellTemplate: '<div ng-show="{{COL_FIELD}}=="female""><i class="fa fa-{{COL_FIELD}}"></i>{{COL_FIELD}}</div>'

http://plnkr.co/edit/JLm5GS5J8530Rutjly31?p=preview

redapplewithleaves avatar Apr 10 '15 14:04 redapplewithleaves

That should also work, yes, but I think you don't use a binding inside ng-show, so it would be COL_FIELD === 'female'

PaulL1 avatar Apr 10 '15 19:04 PaulL1

Ah, thank you :D That worked out great.

redapplewithleaves avatar Apr 10 '15 20:04 redapplewithleaves