2017-09-09 7 views
2

"私は20のレコードをナビゲーションタブに表示しましたが、各レコードに対してチェックボックスにcoloumnを追加しました。 、8チェックボックスを使用して、ナビゲーションタブの上にある "編集"ボタンをクリックすると、ユーザーが編集できるようにModal画面に表示されるはずですチェックボックスを使用してユーザーの選択に基づいてモーダル画面上のデータを表示

もしレコードを選択した場合は、5, 8, 6レコードはその特定の順序。

私はそれをgoogleしましたが、関連する投稿は見つかりませんでした。

<div ng-app="RecordApp" ng-controller="recordcontroller" class="container-fluid"> 

    <div class="input-group"> 
     <ul class="nav nav-tabs"> 
      <li role="menu" class="active"><a href="#" data-toggle="tab" >User Data</a></li> 
     </ul> 

     <table class="table"> 
      <thead> 
       <tr> 

        <th> 
         <a href="#">Select</a> 
        </th> 
        <th> 
         <a href="#" ng-click="SortBy = 'Test1'; Reverse = !Reverse;">Test1</a> 
        </th> 
        <th> 
         <a href="#" ng-click="SortBy = 'Test2'; Reverse = !Reverse;">Test2</a> 
        </th> 
        <th> 
         <a href="#" ng-click="SortBy = 'Test3'; Reverse = !Reverse;">Test3</a> 
        </th> 

       </tr> 
      </thead> 
      <tbody> 
       <tr ng-repeat="record in Records | orderBy:SortBy:Reverse "> 



        <td> 
         <input type="checkbox" checked="checked" ng-model="record.Selected" ng-change="Checked(record)" /> 
        </td> 

        <td>{{ record.Test1 }}</td> 
        <td>{{ record.Test2 }}</td> 
        <td>{{ record.Test3 }}</td> 
       </tr> 
      </tbody> 
     </table> 
    </div> 

次は、ナビゲーションタブの下

$http.get(pageBaseUrl + "api/records").success(function (records) { 
     $scope.Records = records; 
     $scope.IsLoading = false; 
    }); 

を取り込むための私のAngularJsコードされるボタンやモーダル画面のコードです:

<div class="input-group"> 
        <button type="button" data-target="#editRecords" data-toggle="modal" class="btn btn-primary navbar-btn"> 
         <span class="glyphicon glyphicon-floppy-disk"></span> 
         Edit Multiple Records 
        </button> 
       </div> 

    <div id="editRecords" class="modal" role="dialog" aria-hidden="true"> 
     <div class="modal-dialog"> 
      <div class="modal-content"> 
       <div class="modal-header"> 
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button> 
        <h2>Edit Data For Selected Records </h2> 
       </div> 
       <div class="modal-body"> 
        <table class="table-condensed table-striped"> 
         <thead> 
          <tr> 
           <th>Test 1</th> 
           <th>Test 2</th> 
           <th>Test 3</th> 
          </tr> 
         </thead> 
         <tbody> 
          <tr ng-repeat="record in Records | orderBy:SortBy:Reverse"> 
           <td><input type="text" class="form-control input-sm" /></td> 
           <td><input type="text" class="form-control input-sm" /></td> 
           <td><input type="text" class="form-control input-sm" /></td> 
          </tr> 
         </tbody> 
        </table> 
       </div> 
       <div class="modal-footer"> 
        <button type="button" class="btn btn-primary" ng-click="SaveRecords();">Save Records</button> 
        <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="UnmarkForEdition()"> 
         Cancel 
        </button> 
       </div> 
      </div> 
     </div> 
    </div> 
+0

編集用のボタンはどこですか?モーダルHTMLはどこですか? –

+0

私の悪いです。ナビゲーションタブの上に表示されます。私は現在自分のコードで遊んでいるので、言及するのを忘れてしまった。 –

+0

モーダルHTMLとボタンコードも共有できますか。 –

答えて

1

ありがとう10以下は私のHTMLコードですコードは、ここに私の解決策です、

JSFiddle Demo

問題:

第1の目的は、コードを使用して、任意選択のチェックボックスが含まれている場合、私は確認してください。プロパティSelected:trueを含む任意のオブジェクトがある場合、上記のコードで

$scope.checkCheckbox = function(){ 
    return $filter('filter')($scope.Records, {Selected: true}).length === 0; 
} 

は、私は ng-repeat配列を確認し、何も存在しない場合、長さは、比較演算子を使用してゼロになり、Iは、ブール値を返します。これは、HTML要素 button属性 ng-disabledによって使用され、入力を無効にします。

<button type="button" ng-disabled="checkCheckbox()" data-target="#editRecords" data-toggle="modal" class="btn btn-primary navbar-btn"> 
       <span class="glyphicon glyphicon-floppy-disk"></span> 
       Edit Multiple Records 
      </button> 

場合はチェックボックスが選択されている入力のみが表示されますedit multiple records, button is clicked, I open the modal, and in the code I have added a simple NG-if`!

<tr ng-if="record.Selected" ng-repeat="record in Records | orderBy:SortBy:Reverse"> 
           <td><input type="text" class="form-control input-sm" /></td> 
           <td><input type="text" class="form-control input-sm" /></td> 
           <td><input type="text" class="form-control input-sm" /></td> 
          </tr> 

これで問題が解決するかどうかを教えてください。

+0

優しいよ!これは私が探している論理です。さらに2つのことをしてください:1。編集中にモーダル画面上にナビゲーションタブレコードを表示し、モーダル画面上のレコードがチェックボックスを選択した順序で表示されます。 - テスト1 = 1、テスト2 = 2、テスト3 = 3レコード2: - テスト1 = 1.1、テスト2 = 2.1、テスト3 = 3.1、レコード3:テスト1 = 1.2、テスト2 = 2.2、 Test3 = 3.3で、ユーザーがレコード2と1を選択してからモーダル画面を表示すると、レコード2、レコード1が表示されます。 –

+0

@ ShalabhSaxenaそうすることはできますか?あなたの問題だけでお手伝いしたいと思います! –

+0

Ok @naren Murali。私はこれを完了させてください。私を助けてくれてありがとう。とても有難い。 –

関連する問題