在像这样的选项中使用UI-Grid的cellTemplate:
field: 'isHflrReplaceable', displayName: 'Lead Replacement', width: 200, enableSorting: false, cellTemplate: hflrTemplate
模板看起来像这样:
var hflrTemplate = '<div class="ui-grid-cell-contents">'
+ '<span class="hflr" ng-show="(row.entity.creditStatus == \'Credit Accepted\') || (row.entity.creditStatus == \'Credit Rejected\')">{{row.entity.creditStatus}}</span>' //IF status = Credit accepted or Rejected
+ '<span class="hflr" ng-show="(row.entity.creditStatus == \'Credit Pending\') && (row.entity.isHflrReplaceable == 1)"><button ng-if="row.entity.isHflrReplaceable == 1" ng-click="grid.appScope.setSelected(row.entity);" type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#HFLRModal"><span class="fa fa-reply m-r-xs"></span>View/Edit</button></span>' //IF status = Credit Pending && can return
+ '<span class="hflr" ng-show="(row.entity.creditStatus == null) && (row.entity.isHflrReplaceable == 1)"><button ng-if="row.entity.isHflrReplaceable == 1" ng-click="grid.appScope.setSelected(row.entity);" type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#HFLRModal"><span class="fa fa-reply m-r-xs"></span>Request Replacement</button></span>' //IF status = null && can return
+ '</div>';
正确的项目按预期显示。列表有点长......大约200行。
当我向上滚动一些长度经过视口然后再向上时,只包含文本的模板跨度很好。但是,模板跨度显示按钮具有相同按钮的附加副本。事实上,当我进一步滚动按钮然后返回按钮时,按钮会不断添加。我检查了DOM,每次滚动回按钮时,都会有一个额外的按钮。到底是怎么回事?
注意:我没有操纵任何数据,我只是使用滚动条滚动表格视图。
答案 0 :(得分:0)
没关系。误报。
看起来有人在按钮中添加了ng-if
。我不知道为什么。并从按钮标签本身中删除它,解决了问题。