AngularJs-仅允许在表中选择一项
我用的是智能桌。我有一个逻辑,我只需要选择一个项目。我的当前表格代码允许选择多行 这是我的HTML:AngularJs-仅允许在表中选择一项,angularjs,html-table,angular-ui-bootstrap,smart-table,Angularjs,Html Table,Angular Ui Bootstrap,Smart Table,我用的是智能桌。我有一个逻辑,我只需要选择一个项目。我的当前表格代码允许选择多行 这是我的HTML: <table st-safe-src="flow3.dataSet" st-table="flow3.displayed" class="table table-striped"> <thead> <tr> <th st-sort="method
<table st-safe-src="flow3.dataSet" st-table="flow3.displayed" class="table table-striped">
<thead>
<tr>
<th st-sort="method">Method</th>
<th st-sort="sample">Sample</th>
<th st-sort="parameters">Parameters</th>
</tr>
</thead>
<tbody ui-sortable ng-model="flow3.displayed">
<tr ng-repeat="row in flow3.displayed track by $index" style="cursor: move;" ng-click="row.selected = !row.selected; flow3.selectRow($event, row)" ng-class="{success: row.selected}">
<td>{{row.method.name}}</td>
<td>{{row.sample}}</td>
<td>
<span ng-repeat="parameter in row.parameters">{{parameter.methodInputParameter.name}} : {{parameter.value}}<br/></span>
</td>
<td>
<button type="button" ng-click="flow3.removeItem(row)"
class="btn btn-danger btn-sm btn-round pull-right"
ng-disabled="flow3.confirmDisabled">
<i class="glyphicon glyphicon-trash"></i>
</button>
</td>
</tr>
</tbody>
</table>
我建议查看智能表github页面和使用指南 特别是与您的问题相关的部分是“选择数据行”
基本上,您需要使用st select row属性和st select模式来配置表行(tr)元素中的单击。我建议您查看智能表github页面并使用指南 特别是与您的问题相关的部分是“选择数据行”
基本上,您需要使用st select row属性和st select模式来配置表行(tr)元素中的单击。如果您只想将
选定的属性设置为true
,则,您应该修改selectRow
方法以接受所有行的集合,然后在选择一行之前取消全选:
flow3.selectRow=函数($event,row,rows){
//全部取消选择
forEach(行,函数(r){r.selected=false;});
//点击选择
row.selected=true;
flow3.selectedItem=行;
}
ng click=“flow3.selectRow($event,row,flow3.dataSet)”
如果您只想将selected
属性设置为true
,则应修改selectRow
方法以接受所有行的集合,然后在选择一行之前取消全选:
flow3.selectRow=函数($event,row,rows){
//全部取消选择
forEach(行,函数(r){r.selected=false;});
//点击选择
row.selected=true;
flow3.selectedItem=行;
}
ng click=“flow3.selectRow($event,row,flow3.dataSet)”
是否要应用不同的类来突出显示该行?您好Stanislav。高亮显示行的类别无关紧要。我不能同时选择两行,你只是想应用不同的类来突出显示行吗?嗨,Stanislav。高亮显示行的类别无关紧要。我只是不能同时选择两行
flow3.selectRow = function($event, row) {
flow3.selectedItem = row;
}