2017-02-13 24 views
0

私は角型アプリで出席データを表示するのにUI-Gridを使用しています。私は出席のための3つのオプションが別々の配列に格納されています。角型グリッドのCelltemplateが正しく機能していない

$scope.gridOptions.data.attendance=[{'persent'},{'absent'},{'leave'}]; 

と学生の数として示されています。今、私はとして出席列にドロップダウンを表示したい

$scope.gridOptions.data=students;//from ajax request 

enter image description here

また、私はcelltemplateとコードでNG-オプションを使用option.so選択デフォルトは似ているようpersentを表示する:

$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 - グリッドの下部にスクロールせずに表示されているグリッドでは、デフォルトのオプションであるpersentが選択されています。

2 - 私がオプションを選択しているとき、それは下のグリッドのいくつかでもランダムに選択されています。

私はこの奇妙な振る舞いを理解できません。

答えて

0

NG-INIT = "row.entity.stdattendnce = row.entity.attendance [0] は、問題を引き起こしてタイプミスです それはplunkrでこれを見るために役立つだろう これは、角度plunkrです:?。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-モデルを使用して、テンプレート内で識別されていることに注意してください。

+0

私の質問は、私は、グリッドでこれを使用することに問題があるです。 –

関連する問題