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 = {}; style={css:{'color':'#ed5565'}}; return style; }