コード例 #1
0
 /**
  * Add columns to grid
  *
  * @return $this
  */
 protected function _prepareColumns()
 {
     if (!$this->isReadonly()) {
         $this->addColumn('in_products', ['type' => 'checkbox', 'name' => 'in_products', 'values' => $this->_getSelectedProducts(), 'align' => 'center', 'index' => 'entity_id', 'header_css_class' => 'col-select', 'column_css_class' => 'col-select']);
     }
     $this->addColumn('entity_id', ['header' => __('ID'), 'sortable' => true, 'index' => 'entity_id', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id']);
     $this->addColumn('name', ['header' => __('Name'), 'index' => 'name', 'header_css_class' => 'col-name', 'column_css_class' => 'col-name']);
     $this->addColumn('sku', ['header' => __('SKU'), 'index' => 'sku', 'header_css_class' => 'col-sku', 'column_css_class' => 'col-sku']);
     $this->addColumn('visibility', ['header' => __('Visibility'), 'index' => 'visibility', 'type' => 'options', 'options' => $this->_visibility->getOptionArray(), 'header_css_class' => 'col-visibility', 'column_css_class' => 'col-visibility']);
     if (!$this->_storeManager->isSingleStoreMode()) {
         $this->addColumn('websites', ['header' => __('Websites'), 'sortable' => false, 'index' => 'websites', 'type' => 'options', 'options' => $this->_websiteFactory->create()->getCollection()->toOptionHash(), 'header_css_class' => 'col-websites', 'column_css_class' => 'col-websites']);
     }
     $this->addColumn('status', ['header' => __('Status'), 'index' => 'status', 'type' => 'options', 'options' => $this->_status->getOptionArray(), 'header_css_class' => 'col-status', 'column_css_class' => 'col-status', 'frame_callback' => array($this->getLayout()->createBlock('Magefan\\Blog\\Block\\Adminhtml\\Grid\\Column\\Statuses'), 'decorateStatus')]);
     return parent::_prepareColumns();
 }
コード例 #2
0
 /**
  * Add columns to grid
  *
  * @return $this
  */
 protected function _prepareColumns()
 {
     if (!$this->isReadonly()) {
         $this->addColumn('in_posts', ['type' => 'checkbox', 'name' => 'in_posts', 'values' => $this->_getSelectedPosts(), 'align' => 'center', 'index' => 'post_id', 'header_css_class' => 'col-select', 'column_css_class' => 'col-select']);
     }
     $this->addColumn('post_id', ['header' => __('ID'), 'sortable' => true, 'index' => 'post_id', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id']);
     $this->addColumn('title', ['header' => __('Title'), 'index' => 'title', 'header_css_class' => 'col-name', 'column_css_class' => 'col-name']);
     $this->addColumn('identifier', ['header' => __('URL Key'), 'index' => 'identifier', 'header_css_class' => 'col-name', 'column_css_class' => 'col-name']);
     /**
      * Check is single store mode
      */
     if (!$this->_storeManager->isSingleStoreMode()) {
         $this->addColumn('store_id', ['header' => __('Store View'), 'index' => 'store_id', 'type' => 'store', 'store_all' => true, 'store_view' => true, 'sortable' => false]);
     }
     $this->addColumn('is_active', ['header' => __('Status'), 'index' => 'is_active', 'type' => 'options', 'options' => $this->_status->getOptionArray(), 'header_css_class' => 'col-status', 'column_css_class' => 'col-status', 'frame_callback' => array($this->getLayout()->createBlock('Magefan\\Blog\\Block\\Adminhtml\\Grid\\Column\\Statuses'), 'decorateStatus')]);
     return parent::_prepareColumns();
 }