ENHANCEMENT: Part of fix to #7010. Change to some gridfield calls to setDisplayFields and friends.

This commit is contained in:
Robert Curry 2012-04-19 11:53:46 +12:00
parent 0e071c9393
commit 7850499687
3 changed files with 15 additions and 11 deletions

View File

@ -139,14 +139,15 @@ JS
new GridFieldDetailForm()
);
$gridField = new GridField('File','Files', $this->getList(), $gridFieldConfig);
$gridField->setDisplayFields(array(
$columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
$columns->setDisplayFields(array(
'StripThumbnail' => '',
// 'Parent.FileName' => 'Folder',
'Title' => _t('File.Name'),
'Created' => _t('AssetAdmin.CREATED', 'Date'),
'Size' => _t('AssetAdmin.SIZE', 'Size'),
));
$gridField->setFieldCasting(array(
$columns->setFieldCasting(array(
'Created' => 'Date->Nice'
));
$gridField->setAttribute(

View File

@ -676,7 +676,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
new GridFieldPaginator(15)
);
$gridField = new GridField('Page','Pages', $list, $gridFieldConfig);
$columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
// Don't allow navigating into children nodes on filtered lists
if($params){
$gridField->setDisplayFields(array(
@ -685,7 +686,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
'LastEdited' => _t('SiteTree.LASTUPDATED', 'Last Updated'),
));
}else{
$gridField->setDisplayFields(array(
$columns->setDisplayFields(array(
'listChildrenLink' => "",
'getTreeTitle' => _t('SiteTree.PAGETITLE', 'Page Title'),
'Created' => _t('SiteTree.CREATED', 'Date Created'),
@ -693,13 +694,13 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
));
}
$gridField->setFieldCasting(array(
$columns->setFieldCasting(array(
'Created' => 'Date->Ago',
'LastEdited' => 'Date->Ago',
));
$controller = $this;
$gridField->setFieldFormatting(array(
$columns->setFieldFormatting(array(
'listChildrenLink' => function(&$item) use($controller) {
$num = $item->numChildren();
if($num) {

View File

@ -162,6 +162,7 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider {
new GridFieldExportButton()
);
$gridField = new GridField('Report',$report->title(), $report->sourceRecords(array(), null, null), $gridFieldConfig);
$columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
$displayFields = array();
$fieldCasting = array();
$fieldFormatting = array();
@ -181,9 +182,9 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider {
$displayFields[$source] = isset($info['title']) ? $info['title'] : $source;
}
$gridField->setDisplayFields($displayFields);
$gridField->setFieldCasting($fieldCasting);
$gridField->setFieldFormatting($fieldFormatting);
$columns->setDisplayFields($displayFields);
$columns->setFieldCasting($fieldCasting);
$columns->setFieldFormatting($fieldFormatting);
$fields->push($gridField);
} else {
@ -195,10 +196,11 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider {
new GridFieldFooter()
);
$gridField = new GridField('Reports','Reports', $this->Reports(), $gridFieldConfig);
$gridField->setDisplayFields(array(
$columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
$columns->setDisplayFields(array(
'title' => 'Title',
));
$gridField->setFieldFormatting(array(
$columns->setFieldFormatting(array(
'title' => '<a href=\"$Link\" class=\"cms-panel-link\">$value</a>'
));
$gridField->addExtraClass('all-reports-gridfield');