bootstrap table定义代码:
$table.bootstrapTable({
showExport: true,
height: 540,
rowStyle:rowStyle,//通过自定义函数设置行样式
columns: [
{
field: 'id',
title: '序号',
align: 'center',
sortable: true
}, {
field: 'sid',
title: '学号',
align: 'center'
},
]
});
bootstrapTable设置行样式(背景颜色)函数示例1
下面的函数通过调用bootstrap默认的样式来设置指定行的背景颜色
function rowStyle(row, index) {
var classes = ['active', 'success', 'info', 'warning', 'danger'];
if (index % 2 === 0 && index / 2 < classes.length) {
return {
classes: classes[index / 2]
};
}
return {};
}
bootstrapTable设置行样式(背景颜色)函数2
下面的函数调用自定义样式设置指定行的字体颜色,偶数行会设置为指定 的背景颜色
function rowStyle(row, index) {
var style = {};
if (index % 2 === 0 && index / 2 < classes.length) {
style={css:{'background-color':'#ed5565'}};
}
return style;
}