当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Adminhtml_Block_Widget_Grid::sortColumnsByOrder方法代码示例

本文整理汇总了PHP中Mage_Adminhtml_Block_Widget_Grid::sortColumnsByOrder方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Adminhtml_Block_Widget_Grid::sortColumnsByOrder方法的具体用法?PHP Mage_Adminhtml_Block_Widget_Grid::sortColumnsByOrder怎么用?PHP Mage_Adminhtml_Block_Widget_Grid::sortColumnsByOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Adminhtml_Block_Widget_Grid的用法示例。


在下文中一共展示了Mage_Adminhtml_Block_Widget_Grid::sortColumnsByOrder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _addActivationStatusColumn

 /**
  * Add the activation status column to the customer grid block.
  *
  * This is used from different events when displaying the block as well as
  * during exporting the grid to CSV or XML.
  *
  * @param Mage_Adminhtml_Block_Widget_Grid $block
  */
 protected function _addActivationStatusColumn(Mage_Adminhtml_Block_Widget_Grid $block)
 {
     /** @var $helper Netzarbeiter_CustomerActivation_Helper_Data */
     $helper = Mage::helper('customeractivation');
     // Add the attribute as a column to the grid
     $block->addColumnAfter('customer_activated', array('header' => $helper->__('Customer Activated'), 'align' => 'center', 'width' => '80px', 'type' => 'options', 'options' => array('0' => $helper->__('No'), '1' => $helper->__('Yes')), 'default' => '0', 'index' => 'customer_activated', 'renderer' => 'customeractivation/adminhtml_widget_grid_column_renderer_boolean'), 'customer_since');
     // Set the new columns order.. otherwise our column would be the last one
     $block->sortColumnsByOrder();
 }
开发者ID:bherrero,项目名称:customer-activation,代码行数:17,代码来源:Observer.php

示例2: 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();
     uasort($columns, array($this, '_sortColumns'));
     $attributes = $this->getAvailableAttributes();
     foreach ($columns as $column) {
         if (!in_array($column['id'], $gridIds)) {
             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($rendererType, $rendererParams, $column['index'], $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));
                 }
                 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
                 $grid->getColumn($column['id'])->setWidth($column['width'])->setAlign($column['align'])->setHeader($column['header']);
                 $columnsOrders[] = $column['id'];
             } else {
                 // Remove not visible columns
                 $grid->blcg_removeColumn($column['id']);
             }
         }
     }
     // Apply columns orders
     $grid->blcg_resetColumnsOrder();
     $previousId = null;
     foreach ($columnsOrders as $columnId) {
         if (!is_null($previousId)) {
             $grid->addColumnsOrder($columnId, $previousId);
         }
         $previousId = $columnId;
     }
     $grid->sortColumnsByOrder();
     return $this;
 }
开发者ID:aram93,项目名称:mage-enhanced-admin-grids,代码行数:82,代码来源:Grid.php


注:本文中的Mage_Adminhtml_Block_Widget_Grid::sortColumnsByOrder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。