可以在Bootstrap表中获取选定的行
我已经在我的ASP.NET网页中定义了以下引导表:
<table class="display table table-bordered" data-click-to-select="true"
data-pagination="true" data-sortable="true" data-show-refresh="true" data-single-select="true" data-maintain-selected="true"
data-show-toggle="true" data-id-field="customer_id" id="customers" name="customers">
<thead>
<tr>
<th data-field="state" data-checkbox="true"></th>
<th data-field="Customer_ID" data-sortable="true">Acct. #</th>
<th data-field="Company_Name" data-sortable="true">Company</th>
<th data-field="Federal_EIN" data-sortable="true">EIN</th>
<th data-field="City" data-sortable="true">City</th>
<th data-field="State" data-sortable="true">State</th>
<th data-field="Creation_Date" data-sortable="true">Added</th>
</tr>
</thead>
</table>
并且,在此上下示例代码之后,我尝试使用以下jQuery/javascript代码来获取和显示来自选定的行的信息:
$('#customers').on('check.bs.table', function (e, row) {
checkedRows.push({ id: row.id, name: row.name, forks: row.forks });
console.log(checkedRows);
$.each(checkedRows, function (index, value) {
$(console.log(value.id + " | " + value.name + " | " + value.forks));
});
});
$('#customers').on('uncheck.bs.table', function (e, row) {
$.each(checkedRows, function (index, value) {
if (value.id === row.id) {
checkedRows.splice(index, 1);
}
});
console.log(checkedRows);
});
问题是,问题是控制台。将检查行的值显示为 undefined
。我在做什么错?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,我发现问题是,
行
对象的字段对细胞敏感性,基于该表格的字段(尽管有趣的是,Bootstrap表不在乎Data-Field 参数可观察病例敏感性!)。因此,一旦我使用适当的情况敏感性来参考
row
的字段,一切都会显示出来。谢谢大家的帮助!
So, I figured out that the issue is, the
row
object's fields are case-sensitive, based on the fields the table is populated with (although interestingly, the bootstrap table doesn't care if thedata-field
parameters observe case-sensitivity!). So, once I used the proper case sensitivity in referring to the fields of therow
, everything showed up.Thank you everyone for your help!