mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
Merge pull request #104 from robert-h-curry/7010-gridfield-set-display-fields
ENHANCEMENT: Part of fix to #7010. Change to some gridfield calls to set...
This commit is contained in:
commit
68a5686cfe
@ -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(
|
||||
|
@ -676,6 +676,7 @@ 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){
|
||||
@ -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) {
|
||||
|
@ -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');
|
||||
|
Loading…
Reference in New Issue
Block a user