0

我有 ui-grid。我的对象是可能包含框或样本的框。Box1 = { 'Name': 'box1', 'Children': [{'Name': 'box2'},{'Name': 'box3'}]} Box2 = { 'Name': 'box2', 'Children ': [], '样本 [{'Name': '1'}]}

一开始我展示的是 Box1。用户可以单击 Box1 或 Box2,然后它会打开一个链接,显示该框包含的内容。

nameLinkTemplate 是链接模板 ("getExternalScopes().followlink) $scope.gridOptions.columnDefs = ({field: 'Name', displayName: 'Name', cellTemplate: nameLinkTemplate});

如果框中包含示例,我将更改列以仅显示没有链接的名称。
$scope.gridOptions.columnDefs = ({field: 'Name', displayName: 'Name2', }); 结果我看不到链接(这就是我想要的),但是没有显示 Ui-Grig 列标题?为什么?

我还尝试通过以下方式重置 Ui-grid: $scope.gridOptions = []; 并再次定义网格。我仍然无法正确更改列 displayName。

4

2 回答 2

1

我刚刚在模板上添加了条件,它可以工作:

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
于 2014-12-10T08:42:42.567 回答
1

更改名称后尝试调用:

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

它对我有用

于 2016-05-04T09:49:59.200 回答