【发布时间】:2016-09-26 01:37:25
【问题描述】:
我正在使用 angular-ui-grid 并尝试显示几个单元格模板的组合。我需要一些网格单元来根据实体的属性更改类/颜色。我需要其他单元格来显示一个可以打开/关闭的按钮,并且如果行实体是“属性”,则仅针对某些行和单元格显示。我想出了一个 cellTemplate 和一个可编辑的CellTemplate 的组合来完成这个。一切似乎都在工作,除了当我单击带有输入字段的单元格的焦点时,它不会失去焦点,并且我收到错误语法错误:令牌'未定义'不是列空的主要表达式表达式 [row.entity[] 从 [row.entity[] 开始。当我编辑单元格时,它会进入输入模式,我可以输入数据,当我点击退出时,它不会失去焦点,它会保持在编辑模式。如果我在网格上移动滚动条,它将失去焦点
这是我的单元格模板:
<div ng-if="row.entity.resultType === 'ATTRIBUTE' && row.entity[col.colDef.field] == 'Pass'" ng-class="grid.appScope.getClassFromTemplate(row, col)">
<button class="ui-grid-cell-btn" type="button" ng-click="grid.appScope.togglePass(row, col)" >
<span class="glyphicon glyphicon-ok green"></span>
</button>
</div>
<div ng-if="row.entity.resultType === 'ATTRIBUTE' && row.entity[col.colDef.field] != 'Pass'" ng-class="grid.appScope.getClassFromTemplate(row, col)">
<button class="ui-grid-cell-btn" type="button" ng-click="grid.appScope.togglePass(row, col)" >
<span class="glyphicon glyphicon-remove red"></span>
</button>
</div>
//what should this template look like?... should be just standard template to display ui grid data
<div ng-if="row !== null && row.entity.resultType !== 'ATTRIBUTE'" class='ui-grid-cell-contents'>
{{MODEL_COL_FIELD}}
</div>
还有我的可编辑单元格模板
<div ng-if="row.entity.resultType === 'ATTRIBUTE' && row.entity[col.colDef.field] == 'Pass'" class='ui-grid-cell-contents'>
<button class="ui-grid-cell-btn" type="button" ng-click="grid.appScope.togglePass(row, col)" >
<span class="glyphicon glyphicon-ok green"></span>
</button>
</div>
<div ng-if="row.entity.resultType === 'ATTRIBUTE' && row.entity[col.colDef.field] != 'Pass'" class='ui-grid-cell-contents'>
<button class="ui-grid-cell-btn" type="button" ng-click="grid.appScope.togglePass(row, col)" >
<span class="glyphicon glyphicon-remove red"></span>
</button>
</div>
<div ng-if="row.entity !== null && row.entity.resultType !== 'ATTRIBUTE'" >
<form name="inputForm">
<input style="background-color: white; !important; color: black !important" type='text' ng-class="'colt' + col.uid" ui-grid-editor ng-model='MODEL_COL_FIELD'>
</form>
</div>
我已经对所有内容进行了空检查,但仍然收到错误,很困惑。请帮忙!
【问题讨论】: