本文整理匯總了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;
}