Bootstrap Table使用整理(三)(2)

<button>获取表格选中结果</button> <table data-classes="table table-hover" data-show-columns="true" data-click-to-select="true" data-single-select="true" > <thead> <tr> <th data-field="state" data-checkbox="true" data-formatter="checkHandle">选择框</th> <th data-field="sno" >编号</th> <th data-field="sname">姓名</th> <th data-field="ssex">性别</th> <th data-field="sbirthday">生日</th> <th data-field="class">课程编号</th> </tr> </thead> </table> /** data-click-to-select 设置行点击是否选中 * data-checkbox 设置列为多选框 * data-formatter 中返回对象的diabled属性控制是否禁用多选框,checked属性控制当前是否被选中 * data-single-select 指定单选模式,即使使用多选框也是单选模式 */ var $table= $('#table1').bootstrapTable({ url:'@Url.Action("GetStudent","DataOne")' }); $table.on('click-row.bs.table', function (e, row, $element) { $('.success').removeClass('success'); $($element).addClass('success'); }); $('#btn1').click(function () { //获取选中结果行,返回数组 //返回结果中包括多选框字段 state=true var result = $table.bootstrapTable('getSelections'); console.info(result); var ids = []; for (var i = 0; i < result.length; i++) { var item = result[i]; ids.push(item.sno); } alert(ids); }); function checkHandle(value, row, index) { if (index === 2) { return { disabled: true }; } if (index === 0) { return { disabled: true, checked: true } } return value; }

Bootstrap Table使用整理(三)

以上所述是小编给大家介绍的Bootstrap Table使用整理(三),希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyxjdp.html