Resources: SilverStripe

Custom HTML in GridField

11 August 2014

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;

Tags: ,

Let's work together