0

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.

1
  • Sorry, but I'm not able to understand your problem. Are there one, two or three grids involved? Maybe you could provide a plunker? Commented Nov 16, 2014 at 21:37

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

Comments

1

after you change the name try calling :

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

it worked for me

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.