Buat tab dan masukkan kisi khusus di dalam tab


22

Saya membuat sebuah grid dengan mengikuti tutorial ini , saya ingin membuat 4 grid lagi, masalahnya adalah saya perlu menambahkan semua grid ini ke tab

sejauh ini saya telah membuat controller untuk memuat blok seperti ini:

class Lime_Customgrid_Adminhtml_CustomController extends Mage_Adminhtml_Controller_Action
{
    public function indexAction()
    {
        $this->_title($this->__('Custom'))->_title($this->__('Custom Lime'));
        $this->loadLayout();
        $this->_setActiveMenu('sales/sales');
        $this->_addContent($this->getLayout()->createBlock('lime_customgrid/adminhtml_table_custom'));
        $this->renderLayout();
    }
}

Blokir> Adminhtml> Tabel> Kustom> Custom.php:

<?php
class Lime_Customgrid_Block_Adminhtml_Table_Custom extends Mage_Adminhtml_Block_Widget_Tabs
{

    public function __construct()
    {
        parent::__construct();
        $this->setId('custom_tabs');
        // $this->setDestElementId('edit_form');
        $this->setTitle(Mage::helper('lime_customgrid')->__('Custom tabs'));
    }


    protected function _beforeToHtml()
    {
        $this->addTab(
            'form_listing',
            array(
                'label'   => Mage::helper('lime_customgrid')->__('Listing'),
                'title'   => Mage::helper('lime_customgrid')->__('Listing'),
                'content' => $this->getLayout()->createBlock(
                    'lime_customgrid/adminhtml_table_custom_tab_grid'
                )
                ->toHtml(),
            )
        );

        $this->addTab(
            'form_attributes_listing',
            array(
                'label'   => Mage::helper('lime_customgrid')->__('Set Attributes'),
                'title'   => Mage::helper('lime_customgrid')->__('Set Attributes'),
                'content' => $this->getLayout()->createBlock(
                    'lime_customgrid/adminhtml_table_custom_tab_grid'
                )
                ->toHtml(),
            )
        );
        return parent::_beforeToHtml();
    }


}

Blokir> Adminhtml> Tabel> Kustom> Tab> Grid.php:

<?php

class Lime_Customgrid_Block_Adminhtml_Table_Custom_Tab_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct()
    {
        parent::__construct();
        $this->setId('lime_order_grid');
        $this->setDefaultSort('increment_id');
        $this->setDefaultDir('DESC');
        $this->setSaveParametersInSession(true);
        $this->setUseAjax(true);
    }

    protected function _prepareCollection()
    {
        $collection = Mage::getResourceModel('sales/order_collection')
            ->join(array('a' => 'sales/order_address'), 'main_table.entity_id = a.parent_id AND a.address_type != \'billing\'', array(
                'city'       => 'city',
                'country_id' => 'country_id'
            ))
            ->join(array('c' => 'customer/customer_group'), 'main_table.customer_group_id = c.customer_group_id', array(
                'customer_group_code' => 'customer_group_code'
            ))
            ->addExpressionFieldToSelect(
                'fullname',
                'CONCAT({{customer_firstname}}, \' \', {{customer_lastname}})',
                array('customer_firstname' => 'main_table.customer_firstname', 'customer_lastname' => 'main_table.customer_lastname'))
            ->addExpressionFieldToSelect(
                'products',
                '(SELECT GROUP_CONCAT(\' \', x.name)
                    FROM sales_flat_order_item x
                    WHERE {{entity_id}} = x.order_id
                        AND x.product_type != \'configurable\')',
                array('entity_id' => 'main_table.entity_id')
            )
        ;

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

    protected function _prepareColumns()
    {
        $helper = Mage::helper('lime_customgrid');
        $currency = (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE);

        $this->addColumn('increment_id', array(
            'header' => $helper->__('Order #'),
            'index'  => 'increment_id'
        ));

        $this->addColumn('purchased_on', array(
            'header' => $helper->__('Purchased On'),
            'type'   => 'datetime',
            'index'  => 'created_at'
        ));

        $this->addColumn('products', array(
            'header'       => $helper->__('Products Purchased'),
            'index'        => 'products',
            'filter_index' => '(SELECT GROUP_CONCAT(\' \', x.name) FROM sales_flat_order_item x WHERE main_table.entity_id = x.order_id AND x.product_type != \'configurable\')'
        ));

        $this->addColumn('fullname', array(
            'header'       => $helper->__('Name'),
            'index'        => 'fullname',
            'filter_index' => 'CONCAT(customer_firstname, \' \', customer_lastname)'
        ));

        $this->addColumn('city', array(
            'header' => $helper->__('City'),
            'index'  => 'city'
        ));

        $this->addColumn('country', array(
            'header'   => $helper->__('Country'),
            'index'    => 'country_id',
            'renderer' => 'adminhtml/widget_grid_column_renderer_country'
        ));

        $this->addColumn('customer_group', array(
            'header' => $helper->__('Customer Group'),
            'index'  => 'customer_group_code'
        ));

        $this->addColumn('grand_total', array(
            'header'        => $helper->__('Grand Total'),
            'index'         => 'grand_total',
            'type'          => 'currency',
            'currency_code' => $currency
        ));

        $this->addColumn('shipping_method', array(
            'header' => $helper->__('Shipping Method'),
            'index'  => 'shipping_description'
        ));

        $this->addColumn('order_status', array(
            'header'  => $helper->__('Status'),
            'index'   => 'status',
            'type'    => 'options',
            'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
        ));

        $this->addExportType('*/*/exportLimeCsv', $helper->__('CSV'));
        $this->addExportType('*/*/exportLimeExcel', $helper->__('Excel XML'));

        return parent::_prepareColumns();
    }

    public function getGridUrl()
    {
        return $this->getUrl('*/*/grid', array('_current'=>true));
    }
}

hasilnya sangat kacau, bahkan ketika saya mengklik untuk memuat halaman berikutnya, itu mengarahkan saya ke admin dashboard:

masukkan deskripsi gambar di sini




Jawaban:


1

Ganti kode ini

$this->_addContent($this->getLayout()->createBlock('lime_customgrid/adminhtml_table_custom'));

dengan berikut ini

$this->_addContent($this->getLayout()->createBlock('lime_customgrid/adminhtml_table_edit'))
     ->_addLeft($this->getLayout()->createBlock('lime_customgrid/adminhtml_table_custom'));

=> buat file edit.php

<?php

class Lime_Customgrid_Block_Adminhtml_Table_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
 {
    /**
    * 
    * @return void
    */
    public function __construct()
    {
        $this->_blockGroup = 'lime_customgrid';
        $this->_controller = 'adminhtml_custom';

        parent::__construct();
    }
}

0

Cukup Periksa Tautan Dibawah & Unduh Modul itu.


https://github.com/webspeaks/productsgrid_magento2


Meskipun tautan ini dapat menjawab pertanyaan, lebih baik untuk memasukkan bagian-bagian penting dari jawaban di sini dan memberikan tautan untuk referensi. Jawaban hanya tautan dapat menjadi tidak valid jika halaman tertaut berubah. - Dari Ulasan
Manashvi Birla

Kode ini terlalu panjang sehingga saya merujuknya untuk mengirim tautan
Dengan menggunakan situs kami, Anda mengakui telah membaca dan memahami Kebijakan Cookie dan Kebijakan Privasi kami.
Licensed under cc by-sa 3.0 with attribution required.