推入数据时默认检查除第一行以外的行 bootstrap table
Rows excluding first one are checked by default when data pushed in bootstrap table
当我使用 bootstraptable 在 table 中填充数据时,默认情况下会检查除第一行以外的所有行。
HTML:
<div class="modal fade" id="tableDivID" tabindex="-1" role="dialog" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog" style="width:95%">
<div class="modal-content " style="margin-top: 20%;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">Caption</h4>
</div>
<div class="modal-body min-height-400">
<div class="row">
<div class="col-sm-12">
<div id="tableId" style="width: 100%"></div>
</div>
</div>
</div>
</div>
</div>
</div>
Javascript:
function populateTableData(){
var data= [];
for(i=0;i<10;i++){
var row = {'id': i, 'sectionCode': 'hello', 'headerName': 'header'+i, 'amount': '123,123'};
data.push(row);
}
var columns = [
{field: 'id',checkbox: true},
{field: 'sectionCode', title:'Section Code',visible: false},
{field: 'headerName', title:'Header Name'},
{field: 'amount', title:'Amount',width: '30%', align:'right'}];
$("#tableId").bootstrapTable('destroy');
$("#tableId").bootstrapTable({
height: 350,
checkboxHeader: true,
columns: columns ,
data: data
});
}
输出:
我不希望在加载数据时选择任何行。 (即取消选中所有行)
如果有人遇到过这个问题,请告诉我你是如何解决的。
function populateTableData(){
var data= [];
for(i=0;i<10;i++){
var row = {'checked': false, id: i, 'sectionCode': 'hello', 'headerName': 'header'+i, 'amount': '123,123'};
data.push(row);
}
}
var columns = [
{field: 'id', title: 'ID'},
{field: 'checked',checkbox: true},
{field: 'sectionCode', title:'Section Code',visible: false},
{field: 'headerName', title:'Header Name'},
{field: 'amount', title:'Amount',width: '30%', align:'right'}
];
尝试将id与checkbox分开,因为第一个id是0,它的计算结果为false,checkbox不被选中,其余的被选中,因为整数(1,2,3...)评估结果为真。
当我使用 bootstraptable 在 table 中填充数据时,默认情况下会检查除第一行以外的所有行。
HTML:
<div class="modal fade" id="tableDivID" tabindex="-1" role="dialog" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog" style="width:95%">
<div class="modal-content " style="margin-top: 20%;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">Caption</h4>
</div>
<div class="modal-body min-height-400">
<div class="row">
<div class="col-sm-12">
<div id="tableId" style="width: 100%"></div>
</div>
</div>
</div>
</div>
</div>
</div>
Javascript:
function populateTableData(){
var data= [];
for(i=0;i<10;i++){
var row = {'id': i, 'sectionCode': 'hello', 'headerName': 'header'+i, 'amount': '123,123'};
data.push(row);
}
var columns = [
{field: 'id',checkbox: true},
{field: 'sectionCode', title:'Section Code',visible: false},
{field: 'headerName', title:'Header Name'},
{field: 'amount', title:'Amount',width: '30%', align:'right'}];
$("#tableId").bootstrapTable('destroy');
$("#tableId").bootstrapTable({
height: 350,
checkboxHeader: true,
columns: columns ,
data: data
});
}
输出:
我不希望在加载数据时选择任何行。 (即取消选中所有行)
如果有人遇到过这个问题,请告诉我你是如何解决的。
function populateTableData(){
var data= [];
for(i=0;i<10;i++){
var row = {'checked': false, id: i, 'sectionCode': 'hello', 'headerName': 'header'+i, 'amount': '123,123'};
data.push(row);
}
}
var columns = [
{field: 'id', title: 'ID'},
{field: 'checked',checkbox: true},
{field: 'sectionCode', title:'Section Code',visible: false},
{field: 'headerName', title:'Header Name'},
{field: 'amount', title:'Amount',width: '30%', align:'right'}
];
尝试将id与checkbox分开,因为第一个id是0,它的计算结果为false,checkbox不被选中,其余的被选中,因为整数(1,2,3...)评估结果为真。