我使用UI-Grid在我的angular应用程序中显示出勤数据。我使用了三个选项,将出勤数据存储在单独的数组中。
$scope.gridOptions.data.attendance=[{'persent'},{'absent'},{'leave'}];学生人数如下所示:
$scope.gridOptions.data=students;//from ajax request现在我想在出席率列中显示下拉列表为。

我还想将当前显示为默认的选定选项,我在celltemplate中使用了ng- option.so,代码如下:
$scope.gridOptions = {
columnDefs: [
{
name: "stdattendance",
displayName: "Attendance",
width: '20%',
cellClass: 'grid-align',
cellTemplate:'<select ng-model="row.entity.stdattendnce" ng-init="row.entity.stdattendnce=row.entity.attendance[0]"
ng-options="s as s.description for s in row.entity.attendance track by s.id"></select>'
}]我所面对的问题是:
1-在未滚动的网格中选择默认选项当前,而在网格的下半部分未选中。
2-当我选择一个选项时,它也被随机选择在一些较低的网格中。
我搞不懂这个奇怪的behavior.will有人能帮我吗?
发布于 2017-02-14 23:06:44
ng-init="row.entity.stdattendnce=row.entity.attendance是打字错误造成的问题吗?在https://plnkr.co/edit/RJZXudKJKBVIKhoxjXW0中看到这一点会有所帮助。
<body ng-app="defaultValueSelect">
<div ng-controller="ExampleController">
<form name="myForm">
<label for="mySelect">Make a choice:</label>
<select name="mySelect" id="mySelect"
ng-options="option.name for option in data.availableOptions track by option.id"
ng-model="data.selectedOption"></select>
</form>
<hr>
<tt>option = {{data.selectedOption}}</tt><br/>
</div>
</body> 请注意,所选选项是在作用域中设置的,并在模板中使用ng-model标识。
https://stackoverflow.com/questions/42206395
复制相似问题