Updated for new GridField API

This commit is contained in:
Christopher Pitt 2015-04-21 09:24:00 +12:00
parent 75be840dce
commit adabc623f6
2 changed files with 11 additions and 22 deletions

View File

@ -1,33 +1,18 @@
<?php <?php
class CommentsGridField extends GridField class CommentsGridField extends GridField {
{
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function newRow($gridfield, $total, $index, $record, $attributes, $content) { protected function newRow($total, $index, $record, $attributes, $content) {
$classes = array('ss-gridfield-item'); if(!isset($attributes['class'])) {
$attributes['class'] = '';
if($index == 0) {
$classes[] = 'first';
} }
if($index == $total - 1) { if($record->IsSpam) {
$classes[] = 'last'; $attributes['class'] .= ' spam';
} }
$classes[] = ($index % 2) ? 'even' : 'odd';
if ($record->IsSpam) {
$classes[] = 'spam';
}
$attributes = array(
'class' => implode(' ', $classes),
'data-id' => $record->ID,
'data-class' => $record->ClassName,
);
return FormField::create_tag( return FormField::create_tag(
'tr', 'tr',
$attributes, $attributes,

View File

@ -1,3 +1,7 @@
.cms table.ss-gridfield-table tr.spam { .cms table.ss-gridfield-table tr.spam {
background-color: #FFD8D8 ; background-color: #FFD8D8;
}
.cms table.ss-gridfield-table tr.spam:hover {
background-color: #FFF2F2;
} }