本文整理汇总了PHP中GridField::setDisplayFields方法的典型用法代码示例。如果您正苦于以下问题:PHP GridField::setDisplayFields方法的具体用法?PHP GridField::setDisplayFields怎么用?PHP GridField::setDisplayFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridField
的用法示例。
在下文中一共展示了GridField::setDisplayFields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ListViewForm
public function ListViewForm(){
$params = $this->request->requestVar('q');
$list = $this->getList($params, $this->request->requestVar('ParentID'));
$gridFieldConfig = GridFieldConfig::create()->addComponents(
new GridFieldSortableHeader(),
new GridFieldDataColumns(),
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(
'getTreeTitle' => _t('SiteTree.PAGETITLE', 'Page Title'),
'Created' => _t('SiteTree.CREATED', 'Date Created'),
'LastEdited' => _t('SiteTree.LASTUPDATED', 'Last Updated'),
));
}else{
$columns->setDisplayFields(array(
'listChildrenLink' => "",
'getTreeTitle' => _t('SiteTree.PAGETITLE', 'Page Title'),
'Created' => _t('SiteTree.CREATED', 'Date Created'),
'LastEdited' => _t('SiteTree.LASTUPDATED', 'Last Updated'),
));
}
$columns->setFieldCasting(array(
'Created' => 'Date->Ago',
'LastEdited' => 'Date->Ago',
));
$controller = $this;
$columns->setFieldFormatting(array(
'listChildrenLink' => function(&$item) use($controller) {
$num = $item->numChildren();
if($num) {
return sprintf(
'<a class="cms-panel-link list-children-link" data-pjax="ListViewForm" data-target-panel="#Form_ListViewForm" href="%s?ParentID=%d&view=list">%s</a>',
$controller->Link(),
$item->ID,
$num
);
}
},
'getTreeTitle' => '<a class=\"cms-panel-link\" href=\"' .
singleton('CMSPageEditController')->Link('show') . '/$ID\">$value</a>'
));
$listview = new Form(
$this,
'ListViewForm',
new FieldList($gridField),
new FieldList()
);
$this->extend('updateListView', $listview);
$listview->disableSecurityToken();
return $listview;
}