bootstrapTable不同行设置不同的行样式

一、设置相对应table数据
var tableData = [
{
id: 1,
id8: 'yellow',
id9: 'xxxxx',
}, {
id: 2,
id8: 'red',
id9: 'xxxxx',
}];
二、设置相对应table数据
function initTable() {
$('#table').bootstrapTable({
pagination: true,
checkbox:true,
striped: true,
rowStyle:rowStyle,//通过自定义函数设置行样式
columns: [

{
field: 'id',
title: '序号'
}, {
field: 'id8',
title: 'xxx'
}, {
field: 'id9',
title: 'xxx'
}
],
data:tableData
})
}

三、每行的样式
function rowStyle(row,index) {
var style = {};
if(row.id8){
style={css:{'color':row.id8}};
}
return style;
}

四:最终效果

 

 

 
posted @ 2020-10-27 11:19  三寸日光  阅读(630)  评论(0)    收藏  举报