0

How to add conditional styling when showing data in ui-grid cellTemplate below: I want to mofify format to be shown as link or no link. Similar to Conditional cell template in ui-grid angularjs.

var myTemplate = '<div>{{getExternalScopes().showName(row.entity)}}</div>'

$scope.gridOptions = {
    columnDefs: [
            { field: 'code' },
            { field: 'name', cellTemplate: myTemplate},
            // field 'link
  ]
};

The expected result should be that name is link or text based on parameter link

Thanks in advance.

Community
  • 1
  • 1
vertti
  • 101
  • 1
  • 4
  • 8

1 Answers1

0

I made conditional template:

cellContainerNameLinkTemplate: 
'
<div class="ui-grid-cell-contents" 
   ng-if = "row.entity.IsSample"
   ng-class = "col.colIndex()">
   <div class = "gridnolinkpointer"> {{grid.getCellValue(row, col)}}</div>
</div>
<div ng-if = "!row.entity.IsSample">
   <div class = "nav nav-pills" ng-class = "col.colIndex()" > 
      <a class = "gridlinkpointer" ng-click = "getExternalScopes().followlink({event:$event,row:row})"> 
      {{grid.getCellValue(row, col)}}</a>
   </div>
</div>
', cellW
LBA
  • 3,859
  • 2
  • 21
  • 60
vertti
  • 101
  • 1
  • 4
  • 8