【发布时间】:2016-08-24 01:20:14
【问题描述】:
我有一个表格,当用户单击表格中的行时,我正在使用该行的选定属性。在另一个面板中,我有一张地图,上面显示了所有员工。表中的每一行都有唯一的 ID,当用户单击地图上的员工图像时,表中的员工行会突出显示。现在,如果表格有 40 行,我会显示垂直滚动条。当我单击 ID 为 40 的员工时,表中的行被选中,但该行未显示在视图中,因为表有滚动条并且它被滚动条隐藏。以下是我的html代码:
<div class="customTable">
<table class="table" id="employeesTable">
<thead class="active">
<tr>
<th>employee ID</th>
<th>employee State</th>
</tr>
</thead>
<tbody>
<div>
<tr ng-repeat="employee in employees ng-class="{'selected':employee.empId == selectedRow}" id="row{{employee.empId}}" " style="cursor: pointer">
<td>{{employee.empId}}</a></td>
<td><span>{{employee.employeeState}}</span></td>
</tr>
</div>
</tbody>
</table>
</div>
现在,当我点击地图上的员工图片时,会调用以下代码:
$scope.employeeDisplay = function(employee){
//to display employee in the table
//called when the employee is clicked on the map
var id = employee.empId;
$('#employeesTable tr').eq(1).removeClass('selected');
$scope.selectedRow = empId //so based on the employee is that particular row is highlighted in the table
}
如果该行不在初始视图中,您能否告诉我该表如何自动显示所选行,例如该表仅显示 20 行,如果选择了 id 为 40 的员工,则该表应滚动到所选行行。
【问题讨论】:
标签: javascript jquery angularjs html