我是全新的淘汰赛,我试图扩展一些绑定数据的例子。绑定到表的数据,使用复选框检索多行数据?
下面显示绑定到一个表对象:
<table>
<tbody data-bind="foreach: Games">
<tr>
<!--<td style="width:auto;">
<input name="GameSelect" type="checkbox" data-bind="value: $data, checked: $parent.selectedGames" />
</td>-->
<td data-bind="text:Name"></td>
<td data-bind="text: Group"></td>
<td>
<select class="form-control" data-bind="options: $parent.GameGroups, optionsText: 'GameGroupName', optionsValue: 'GameGroupId', value: $parent.filter"></select>
</td>
<td>
<button class="btn btn-success btn-sm" data-bind="click: $parent.makeChanges">Change »</button>
</td>
</tr>
</tbody>
</table>
<!--<button class="btn btn-info btn-block" data-bind="click:makeChangesAll">Change All</button>-->
单击更改将获得包含数据该行的对象,并与makechanges功能使用:
self.makeChanges = function (data) {
...
}
我想为每个表格行添加一个复选框,并添加一个按钮来同时获取所有选定的对象,但我无法使其工作。我的一些尝试是在注释掉的代码中。任何人都可以告诉我如何从每行使用makeChanges函数的一个数据对象获取多个用于使用makeChangesAll函数选择的每个复选框?
它看起来像'selectedGames'有你想要的对象。我想你可能需要展示更多的代码。如何设置小提琴? – CrimsonChris
我现在就去吧 – mao