Permalink
Browse files

ENHANCEMENT: Part of fix to #7010. Change to some gridfield calls to …

…setDisplayFields and friends.
  • Loading branch information...
1 parent 0e071c9 commit 7850499687662442359bb84a73139575f277541c @robert-h-curry robert-h-curry committed Apr 18, 2012
Showing with 15 additions and 11 deletions.
  1. +3 −2 code/controllers/AssetAdmin.php
  2. +5 −4 code/controllers/CMSMain.php
  3. +7 −5 code/controllers/ReportAdmin.php
@@ -139,14 +139,15 @@ public function getEditForm($id = null, $fields = null) {
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(
@@ -676,7 +676,8 @@ public function ListViewForm(){
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,21 +686,21 @@ public function ListViewForm(){
'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'),
'LastEdited' => _t('SiteTree.LASTUPDATED', 'Last Updated'),
));
}
- $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) {
@@ -162,6 +162,7 @@ public function getEditForm($id = null, $fields = null) {
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 @@ public function getEditForm($id = null, $fields = null) {
$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 @@ public function getEditForm($id = null, $fields = null) {
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');

0 comments on commit 7850499

Please sign in to comment.