1.改变列颜色

  1. {
  2. title: \'运单编号\',
  3. field: \'waybillNumber\',
  4. align: \'center\',
  5. valign: \'middle\',
  6. cellStyle: function (value, row, index) {
  7. if (row.focusMark == "0") {
  8. return {css: {"background-color": "red"}};
  9. }
  10. if (row.coordinateMark == "1") {
  11. return {css: {"background-color": "#cb7f71"}};
  12. }
  13. if (row.coordinateMark == "2") {
  14. return {css: {"background-color": "#71cbb9"}};
  15. }
  16. return \'\';
  17. }
  18. }

2.改变行颜色

  1. $("#table").bootstrapTable({
  2. url: dataurl,
  3. method: "post",
  4. dataType: "json",
  5. //......
  6. onLoadSuccess: function (row) {
  7. getTdValue(row);
  8. }
  9. });
  10. //当远程数据被加载完成后触发
  11. function getTdValue(row) {
  12. var tableId = document.getElementById("table");
  13. var y = 0;
  14. for (var i = 0; i < row.rows.length; i++) {
  15. //将已标记的数据改变背景颜色
  16. y++;
  17. if (row.rows[i].coordinateMark == "1") {
  18. tableId.rows[y].setAttribute("style", "background-color:#cb7f71");
  19. }
  20. if (row.rows[i].coordinateMark == "2") {
  21. tableId.rows[y].setAttribute("style", "background-color:#71cbb9");
  22. }
  23. if (row.rows[i].focusMark == "0") {
  24. tableId.rows[y].setAttribute("style", "background-color:red");
  25. }
  26. if (row.rows[i].focusMark == "2") {
  27. tableId.rows[y].setAttribute("style", "background-color:#830303");
  28. }
  29. }
  30. }

 

版权声明:本文为tongsi原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/tongsi/p/12703065.html