本文整理汇总了PHP中Mage_Adminhtml_Block_Widget_Grid::blcg_addAdditionalAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Adminhtml_Block_Widget_Grid::blcg_addAdditionalAttribute方法的具体用法?PHP Mage_Adminhtml_Block_Widget_Grid::blcg_addAdditionalAttribute怎么用?PHP Mage_Adminhtml_Block_Widget_Grid::blcg_addAdditionalAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Adminhtml_Block_Widget_Grid
的用法示例。
在下文中一共展示了Mage_Adminhtml_Block_Widget_Grid::blcg_addAdditionalAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: applyColumnsToGridBlock
/**
* Apply columns values to grid block
*
* @param Mage_Adminhtml_Block_Widget_Grid $grid Grid block instance
* @param bool $applyFromCollection Whether values from collection columns should be applied
* @return this
*/
public function applyColumnsToGridBlock(Mage_Adminhtml_Block_Widget_Grid $grid, $applyFromCollection)
{
$gridIds = array_keys($grid->getColumns());
$columnsOrders = array();
$columns = $this->getColumns(false, true);
uasort($columns, array($this, '_sortColumns'));
$attributes = $this->getAvailableAttributes();
foreach ($columns as $column) {
if (!in_array($column['id'], $gridIds, true)) {
if ($column['is_visible'] && !$column['missing'] && (!$this->isCollectionColumnOrigin($column['origin']) || $applyFromCollection)) {
// Add from collection/attribute visible and not missing columns
$lockedValues = $this->getColumnLockedValues($column['id']);
$data = array('header' => $column['header'], 'align' => $column['align'], 'width' => $column['width'], 'index' => $column['index']);
$data = array_merge($data, array_intersect_key($lockedValues, $data));
if ($this->isCollectionColumnOrigin($column['origin'])) {
if (isset($lockedValues['renderer']) || !is_null($column['renderer_type'])) {
// Add collection specific column values
if (isset($lockedValues['renderer'])) {
$rendererType = $lockedValues['renderer'];
$rendererParams = $rendererType == $column['renderer_type'] ? $column['renderer_params'] : array();
} else {
$rendererType = $column['renderer_type'];
$rendererParams = $column['renderer_params'];
}
$data = array_merge($data, $this->_getCollectionColumnGridValues($column['index'], $rendererType, $rendererParams, $grid->blcg_getStore()));
}
} elseif ($this->isAttributeColumnOrigin($column['origin'])) {
if (!isset($attributes[$column['index']])) {
// Unknown attribute
continue;
}
if (is_null($column['store_id'])) {
// Grid's store
$store = $grid->blcg_getStore();
} else {
// Specific store
$store = Mage::app()->getStore($column['store_id']);
}
// Use auto-generated unique ID as index
$alias = self::GRID_COLUMN_ATTRIBUTE_GRID_ALIAS . str_replace(self::GRID_COLUMN_ATTRIBUTE_ID_PREFIX, '', $column['id']);
$data['index'] = $alias;
// Tell grid to select current attribute
$grid->blcg_addAdditionalAttribute(array('alias' => $alias, 'attribute' => $attributes[$column['index']], 'bind' => 'entity_id', 'filter' => null, 'join_type' => 'left', 'store_id' => $store->getId()));
// Add attribute specific column values
$data = array_merge($data, $this->_getAttributeColumnGridValues($attributes[$column['index']], $column['renderer_params'], $store));
} elseif ($this->isCustomColumnOrigin($column['origin'])) {
if (!is_object($column['custom_column'])) {
// Unknown column
continue;
}
if (is_null($column['store_id'])) {
// Grid's store
$store = $grid->blcg_getStore();
} else {
// Specific store
$store = Mage::app()->getStore($column['store_id']);
}
// Use auto-generated unique ID as index
$alias = self::GRID_COLUMN_CUSTOM_GRID_ALIAS . str_replace(self::GRID_COLUMN_CUSTOM_ID_PREFIX, '', $column['id']);
$data['index'] = $alias;
// Add attribute specific column values
$customValues = $this->_getCustomColumnGridvalues($column['id'], $data['index'], $column['custom_column'], $column['renderer_type'], $column['renderer_params'], $column['custom_params'], $store, $grid);
if (!is_array($customValues)) {
// An error occured while applying custom column
continue;
}
$data = array_merge($data, $customValues);
}
if (isset($lockedValues['config_values']) && is_array($lockedValues['config_values'])) {
$data = array_merge($data, $lockedValues['config_values']);
}
$grid->addColumn($column['id'], $data);
$columnsOrders[] = $column['id'];
}
} else {
if ($column['is_visible']) {
// Update visible columns
if ($gridColumn = $grid->getColumn($column['id'])) {
if (!$this->getIgnoreCustomWidths()) {
$gridColumn->setWidth($column['width']);
}
if (!$this->getIgnoreCustomAlignments()) {
$gridColumn->setAlign($column['align']);
}
if (!$this->getIgnoreCustomHeaders()) {
$gridColumn->setHeader($column['header']);
}
}
$columnsOrders[] = $column['id'];
} else {
// Remove not visible columns
$grid->blcg_removeColumn($column['id']);
}
//.........这里部分代码省略.........