SilverStripe

Custom HTML in GridField

GridFields are great, but sometimes you need to jazz them up with your own HTML or images to make it more user-friendly. Especially when handling huge tables!

You can create custom HTML using the following method in your DataObject:

static $summary_fields = array(
  'ColumnDataHTML' => 'Column Heading'
);

function ColumnDataHTML(){
  $html = HTMLText::create();
  $html->setValue('<div style="background-color: '.$this->Colour.'; width: 100px; height: 100px;">&nbsp;</div>');
  return $html;
}