本文整理匯總了PHP中GridField::getColumns方法的典型用法代碼示例。如果您正苦於以下問題:PHP GridField::getColumns方法的具體用法?PHP GridField::getColumns怎麽用?PHP GridField::getColumns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GridField
的用法示例。
在下文中一共展示了GridField::getColumns方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getHTMLFragments
/**
* @param GridField $grid
* @return array
*/
public function getHTMLFragments($grid)
{
$cols = new ArrayList();
foreach ($grid->getColumns() as $name) {
$meta = $grid->getColumnMetadata($name);
$cols->push(new ArrayData(array('Name' => $name, 'Title' => $meta['title'])));
}
$days = new ArrayList();
for ($i = 0; $i < 5; $i++) {
$date = new Date();
$date->setValue(date('d-m-Y', strtotime('+' . $i . ' days', strtotime($this->startDate))));
$isHoliday = in_array($date->Format('Y-m-d'), $this->holidays);
$days->push(new ArrayData(array('Day' => $date->Format('l'), 'IsHoliday' => $isHoliday)));
}
return array('header' => $cols->renderWith('RosterGridFieldTitleHeader', array('StartDate' => $this->startDate, 'Days' => $days)));
}
開發者ID:helpfulrobot,項目名稱:danae-miller-clendon-silverstripe-roster,代碼行數:20,代碼來源:RosterGridFieldTitleHeader.php
示例2: testGetColumns
/**
* @covers GridField::getColumns
*/
public function testGetColumns()
{
$obj = new GridField('testfield', 'testfield', Member::get());
$expected = array(0 => 'FirstName', 1 => 'Surname', 2 => 'Email');
$this->assertEquals($expected, $obj->getColumns());
}
示例3: getHTMLFragments
/**
* @param GridField $gridField
*
* @return array
*/
public function getHTMLFragments($gridField)
{
Requirements::css(BULKEDITTOOLS_MANAGER_PATH . '/css/GridFieldBulkManager.css');
Requirements::javascript(BULKEDITTOOLS_MANAGER_PATH . '/javascript/GridFieldBulkManager.js');
Requirements::add_i18n_javascript(BULKEDITTOOLS_PATH . '/lang/js');
if (!count($this->config['actions'])) {
user_error('Trying to use GridFieldBulkManager without any bulk action.', E_USER_ERROR);
}
$actionsListSource = array();
$actionsConfig = array();
foreach ($this->config['actions'] as $action => $actionData) {
$actionsListSource[$action] = $actionData['label'];
$actionsConfig[$action] = $actionData['config'];
}
reset($this->config['actions']);
$firstAction = key($this->config['actions']);
$dropDownActionsList = DropdownField::create('bulkActionName', '')->setSource($actionsListSource)->setAttribute('class', 'bulkActionName no-change-track')->setAttribute('id', '');
$templateData = array('Menu' => $dropDownActionsList->FieldHolder(), 'Button' => array('Label' => _t('GRIDFIELD_BULK_MANAGER.ACTION_BTN_LABEL', 'Go'), 'DataURL' => $gridField->Link('bulkAction'), 'Icon' => $this->config['actions'][$firstAction]['config']['icon'], 'DataConfig' => htmlspecialchars(json_encode($actionsConfig), ENT_QUOTES, 'UTF-8')), 'Select' => array('Label' => _t('GRIDFIELD_BULK_MANAGER.SELECT_ALL_LABEL', 'Select all')), 'Colspan' => count($gridField->getColumns()) - 1);
$templateData = new ArrayData($templateData);
return array('header' => $templateData->renderWith('BulkManagerButtons'));
}
示例4: getHTMLFragments
/**
*
* @param GridField $gridField
* @return array
*/
public function getHTMLFragments($gridField) {
if(!$this->checkDataType($gridField->getList())) return;
$state = $gridField->State->GridFieldPaginator;
if(!is_int($state->currentPage))
$state->currentPage = 1;
// Figure out which page and record range we're on
$totalRows = $this->totalItems;
if(!$totalRows) return array();
$totalPages = ceil($totalRows/$this->itemsPerPage);
if($totalPages == 0)
$totalPages = 1;
$firstShownRecord = ($state->currentPage - 1) * $this->itemsPerPage + 1;
if($firstShownRecord > $totalRows)
$firstShownRecord = $totalRows;
$lastShownRecord = $state->currentPage * $this->itemsPerPage;
if($lastShownRecord > $totalRows)
$lastShownRecord = $totalRows;
// First page button
$firstPage = new GridField_FormAction($gridField, 'pagination_first', 'First', 'paginate', 1);
$firstPage->addExtraClass('ss-gridfield-firstpage');
if($state->currentPage == 1)
$firstPage = $firstPage->performDisabledTransformation();
// Previous page button
$previousPageNum = $state->currentPage <= 1 ? 1 : $state->currentPage - 1;
$previousPage = new GridField_FormAction($gridField, 'pagination_prev', 'Previous', 'paginate', $previousPageNum);
$previousPage->addExtraClass('ss-gridfield-previouspage');
if($state->currentPage == 1)
$previousPage = $previousPage->performDisabledTransformation();
// Next page button
$nextPageNum = $state->currentPage >= $totalPages ? $totalPages : $state->currentPage + 1;
$nextPage = new GridField_FormAction($gridField, 'pagination_next', 'Next', 'paginate', $nextPageNum);
$nextPage->addExtraClass('ss-gridfield-nextpage');
if($state->currentPage == $totalPages)
$nextPage = $nextPage->performDisabledTransformation();
// Last page button
$lastPage = new GridField_FormAction($gridField, 'pagination_last', 'Last', 'paginate', $totalPages);
$lastPage->addExtraClass('ss-gridfield-lastpage');
if($state->currentPage == $totalPages)
$lastPage = $lastPage->performDisabledTransformation();
// Render in template
$forTemplate = new ArrayData(array(
'FirstPage' => $firstPage,
'PreviousPage' => $previousPage,
'CurrentPageNum' => $state->currentPage,
'NumPages' => $totalPages,
'NextPage' => $nextPage,
'LastPage' => $lastPage,
'FirstShownRecord' => $firstShownRecord,
'LastShownRecord' => $lastShownRecord,
'NumRecords' => $totalRows
));
return array(
'footer' => $forTemplate->renderWith('GridFieldPaginator_Row', array('Colspan'=>count($gridField->getColumns()))),
);
}
示例5: testGetColumns
/**
* @covers GridField::getColumns
*/
public function testGetColumns(){
$obj = new GridField('testfield', 'testfield', DataList::create('Member'));
$expected = array (
0 => 'FirstName',
1 => 'Surname',
2 => 'Email',
);
$this->assertEquals($expected, $obj->getColumns());
}
示例6: getHTMLFragments
/**
*
* @param GridField $gridField
* @return array
*/
public function getHTMLFragments($gridField)
{
if (!$this->checkDataType($gridField->getList())) {
return;
}
$state = $gridField->State->GridFieldPaginator;
if (!is_int($state->currentPage)) {
$state->currentPage = 1;
}
// Figure out which page and record range we're on
$totalRows = $this->totalItems;
if (!$totalRows) {
return array();
}
$totalPages = (int) ceil($totalRows / $this->itemsPerPage);
if ($totalPages == 0) {
$totalPages = 1;
}
$firstShownRecord = ($state->currentPage - 1) * $this->itemsPerPage + 1;
if ($firstShownRecord > $totalRows) {
$firstShownRecord = $totalRows;
}
$lastShownRecord = $state->currentPage * $this->itemsPerPage;
if ($lastShownRecord > $totalRows) {
$lastShownRecord = $totalRows;
}
// If there is only 1 page for all the records in list, we don't need to go further
// to sort out those first page, last page, pre and next pages, etc
// we are not render those in to the paginator.
if ($totalPages === 1) {
$forTemplate = new ArrayData(array('OnlyOnePage' => true, 'FirstShownRecord' => $firstShownRecord, 'LastShownRecord' => $lastShownRecord, 'NumRecords' => $totalRows));
} else {
// First page button
$firstPage = new GridField_FormAction($gridField, 'pagination_first', 'First', 'paginate', 1);
$firstPage->addExtraClass('ss-gridfield-firstpage');
if ($state->currentPage == 1) {
$firstPage = $firstPage->performDisabledTransformation();
}
// Previous page button
$previousPageNum = $state->currentPage <= 1 ? 1 : $state->currentPage - 1;
$previousPage = new GridField_FormAction($gridField, 'pagination_prev', 'Previous', 'paginate', $previousPageNum);
$previousPage->addExtraClass('ss-gridfield-previouspage');
if ($state->currentPage == 1) {
$previousPage = $previousPage->performDisabledTransformation();
}
// Next page button
$nextPageNum = $state->currentPage >= $totalPages ? $totalPages : $state->currentPage + 1;
$nextPage = new GridField_FormAction($gridField, 'pagination_next', 'Next', 'paginate', $nextPageNum);
$nextPage->addExtraClass('ss-gridfield-nextpage');
if ($state->currentPage == $totalPages) {
$nextPage = $nextPage->performDisabledTransformation();
}
// Last page button
$lastPage = new GridField_FormAction($gridField, 'pagination_last', 'Last', 'paginate', $totalPages);
$lastPage->addExtraClass('ss-gridfield-lastpage');
if ($state->currentPage == $totalPages) {
$lastPage = $lastPage->performDisabledTransformation();
}
// Render in template
$forTemplate = new ArrayData(array('OnlyOnePage' => false, 'FirstPage' => $firstPage, 'PreviousPage' => $previousPage, 'CurrentPageNum' => $state->currentPage, 'NumPages' => $totalPages, 'NextPage' => $nextPage, 'LastPage' => $lastPage, 'FirstShownRecord' => $firstShownRecord, 'LastShownRecord' => $lastShownRecord, 'NumRecords' => $totalRows));
}
return array('footer' => $forTemplate->renderWith('GridFieldPaginator_Row', array('Colspan' => count($gridField->getColumns()))));
}