bootstrapTable动态修改columns可使用refreshOptions方法
if (type === 'simple') {
// 简化列:ID、姓名、地址
newColumns = [
{ field: 'id', title: 'ID', align: 'center', width: 80 },
{ field: 'name', title: '姓名', align: 'center' },
{ field: 'address', title: '地址', align: 'center' }
];
} else if (type === 'full') {
// 完整列:所有字段
newColumns = [
{ field: 'id', title: 'ID', align: 'center', width: 80 },
{ field: 'name', title: '姓名', align: 'center' },
{ field: 'age', title: '年龄', align: 'center', width: 80 },
{ field: 'gender', title: '性别', align: 'center', width: 80 },
{ field: 'address', title: '地址', align: 'center' }
];
}
// 正确用法:用 refreshOptions修改 columns 配置,再刷新
$('#myTable').bootstrapTable('refreshOptions', {
columns: newColumns // 批量设置配置项(可同时加 data: 新数据)
});

被折叠的 条评论
为什么被折叠?



