1

I wish to show customer name,email and some customer attributes values in a separate grid please provide me a solution, how to replace a below code to show customer and its attribute values.

protected function _prepareCollection()
    {
        $collection = $model = $this->_model->create()->getCollection();

        $this->setCollection($collection);
        parent::_prepareCollection();
        return $this;
    }

Thanks in advance

0

After prepare collection you need to define columns

protected function _prepareColumns()
    {
        $this->addColumn(
            'database_field_name',
            [
                'header' => __('ID'),
                'type' => 'number',
                'index' => 'database_field_name',
                'header_css_class' => 'col-id',
                'column_css_class' => 'col-id'
            ]
        );
      $this->addColumn(
        'contact_email',
        [
            'header' => __('Contact Email'),
            'index' => 'contact_email',
        ]
        );

        $this->addExportType($this->getUrl('company/*/exportCsv', ['_current' => true]), __('CSV'));
        $this->addExportType($this->getUrl('company/*/exportExcel', ['_current' => true]), __('Excel XML'));

        $block = $this->getLayout()->getBlock('grid.bottom.links');
        if ($block) {
            $this->setChild('grid.bottom.links', $block);
        }

        return parent::_prepareColumns();
    }
1
  • Thanks, for your response, I need to replace the _prepareCollection function() not prepare columns(), Please read the post once again – Jaisa Mar 4 '19 at 11:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.