【发布时间】:2018-02-18 05:46:44
【问题描述】:
“我在导航选项卡中显示了20 记录,并针对每条记录添加了复选框列。我的要求是用户是否使用复选框选择记录(行)1、4、8 并单击“编辑”导航选项卡顶部的按钮,然后它应该显示在Modal 屏幕上,以便用户可以编辑它。
如果他/她选择记录5, 8, 6,则记录应按特定顺序显示。
我用谷歌搜索,但找不到任何相关帖子。
下面是我的 HTML 代码:
<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>
以下是我用于填充导航选项卡的AngularJs 代码
$http.get(pageBaseUrl + "api/records").success(function (records) {
$scope.Records = records;
$scope.IsLoading = false;
});
下面是Button和Modal界面的代码:
<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">×</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>
【问题讨论】:
-
编辑按钮在哪里?模态 HTML 在哪里?
-
我的错。它应该在导航选项卡的顶部。由于我目前正在使用我的代码,所以忘了提及它。
-
能否也分享模态 HTML 和按钮代码!
-
好的。让给你。
-
@NarenMurali 我已经用按钮和模态屏幕代码更新了我的问题。
标签: checkbox angularjs-ng-repeat