0
votes

I have ui-grid. My objects are boxes that may contain boxes or Samples. Box1 = { 'Name': 'box1', 'Children': [{'Name': 'box2'},{'Name': 'box3'}]} Box2 = { 'Name': 'box2', 'Children': [], 'Samples [{'Name': '1'}]}

At the beginning I show Box1. User can click Box1 or Box2 and then it opens a link that shows what the box contains.

nameLinkTemplate is link template ("getExternalScopes().followlink) $scope.gridOptions.columnDefs = ({field: 'Name', displayName: 'Name', cellTemplate: nameLinkTemplate});

If box contains samples I change column to show just name without link.
$scope.gridOptions.columnDefs = ({field: 'Name', displayName: 'Name2', }); As a result I do not see link (that is what I wanted), but Ui-Grig column headers are not displayed? Why?

I have also tried to reset the Ui-grid by: $scope.gridOptions = []; And define the grid again. Still I cannot change column displayName correctly.

2
Sorry, but I'm not able to understand your problem. Are there one, two or three grids involved? Maybe you could provide a plunker? - nabinca

2 Answers

1
votes

I just added conditions on template and it works:

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()" ng-click="getExternalScopes().followlink({event:$event,row:row})">
            <a class="gridlinkpointer">{{grid.getCellValue(row, col)}}</a>
        </div>
    </div>
cell
1
votes

after you change the name try calling :

$scope.gridApi.core.notifyDataChange( uiGridConstants.dataChange.COLUMN );

it worked for me