Answers for "jquery datatable column background color"

1

jquery datatable text color

$(document).ready( function () {
  var table = $('#example').DataTable({
    columnDefs: [{targets: [0, 1, 2, 3, 4, 5],
                    render: function ( data, type, row ) {
                      var color = 'green';
                      if (data == "example") {
                        color = 'green';
                      } 
                      if (data > 10) {
                        color = 'blue';
                      }
                      if (data < 60) {
                        color = 'red';
                      }
                      return '<span style="color:' + color + '">' + data + '</span>';
                    }
               }]
  });
} );
Posted by: Guest on June-05-2021
1

jtable set column background color

table.getColumn("Column title").setCellRenderer(
                new DefaultTableCellRenderer() {
            @Override
            public Component getTableCellRendererComponent(JTable table,
                    Object value, boolean isSelected, boolean hasFocus, int row, int col) {

                super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);

                Float quantityRemaining = (Float) table.getModel().getValueAt(row, col);
                    if (quantityRemaining < 1) {
                        setBackground(table.getBackground());
                        setForeground(Color.RED);
                        setToolTipText("This item needs immediate restocking!!!");
                    } else {
                        setBackground(table.getBackground());
                        setForeground(table.getForeground());
                        setToolTipText("Resonable stock quantities");
                    }
                return table;
            }
        });
    }
Posted by: Guest on April-22-2021

Code answers related to "jquery datatable column background color"

Browse Popular Code Answers by Language