0

First image that with the GiftRegistry tab of the customer

Second image after changing view filter to 30

Third image that's show the disappearing grid on filter First image that with the GiftRegistry tab of the customer Second image after changing view filter to 30 Third image that's show the disappearing grid on filter

So I created the folders for the module

I added in path app/code/local/Mdg/Giftregistry/Block/Adminhtml/Customer/Edit/Tab/Giftregistry.php

    <?php
class Mdg_Giftregistry_Block_Adminhtml_Customer_Edit_Tab_Giftregistry
    extends Mage_Adminhtml_Block_Template
    implements Mage_Adminhtml_Block_Widget_Tab_Interface {

    public function __construct()
    {
        $this->setTemplate('mdg/giftregistry/customer/main.phtml');
        parent::_construct();
    }

    public function getCustomerId()
    {
        return Mage::registry('current_customer')->getId();
    }

    public function getTabLabel()
    {
        return $this->__('GiftRegistry List');
    }

    public function getTabTitle()
    {
        return $this->__('Click to view the customer Gift Registries');
    }

    public function canShowTab()
    {
        return true;
    }

    public function isHidden()
    {
        return false;
    }
}

Then I added in path app/code/local/Mdg/Giftregistry/Block/Adminhtml/Customer/Edit/Tab/Giftregistry/List.php

<?php
   class Mdg_Giftregistry_Block_Adminhtml_Customer_Edit_Tab_Giftregistry_List extends 
   Mage_Adminhtml_Block_Widget_Grid{

public function __construct()
{
    parent::__construct();
    $this->setId('registryList');
    $this->setUseAjax(true);
    $this->setDefaultSort('event_date');
    $this->setFilterVisibility(true);
    $this->setPagerVisibility(true);
}

protected function _prepareCollection()
{
    $collection = Mage::getModel('mdg_giftregistry/entity')
        ->getCollection()
        ->addFieldToFilter('main_table.customer_id', $this->getRequest()->getParam('id'));
    $this->setCollection($collection);
    return parent::_prepareCollection();
}

protected function _prepareColumns()
{
    $this->addColumn('entity_id', array(
        'header'   => Mage::helper('mdg_giftregistry')->__('Id'),
        'width'    => 50,
        'index'    => 'entity_id',
        'sortable' => false,
    ));

    $this->addColumn('event_location', array(
        'header'   => Mage::helper('mdg_giftregistry')->__('Location'),
        'index'    => 'event_location',
        'sortable' => false,
    ));

    $this->addColumn('event_date', array(
        'header'   => Mage::helper('mdg_giftregistry')->__('Event Date'),
        'index'    => 'event_date',
        'sortable' => false,
    ));

    $this->addColumn('type_id', array(
        'header'   => Mage::helper('mdg_giftregistry')->__('Event Type'),
        'index'    => 'type_id',
        'sortable' => false,
    ));
    return parent::_prepareColumns();
}}

Then I added the template file on path app/design/adminhtml/default/default/template/mdg/giftregistry/customer/main.phtml

<div class="entry-edit">
<div class="entry-edit-head">
    <h4 class="icon-head head-customer-view"><?php echo $this->__('Customer Gift Registry List') ?></h4>
</div>
<?php echo $this->getChildHtml('tab_giftregistry_list'); ?>

Then I loaded the layout on path app/design/adminhtml/default/default/layout/giftregistry.xml

<layout version="0.1.0">
    <adminhtml_customer_edit>
        <reference name="left">
            <reference name="customer_edit_tabs">
                <block type="mdg_giftregistry/adminhtml_customer_edit_tab_giftregistry" name="tab_giftregistry_main" template="mdg/giftregistry/customer/main.phtml">
                    <block type="mdg_giftregistry/adminhtml_customer_edit_tab_giftregistry_list" name="tab_giftregistry_list" as="tab_giftregistry_list" />
                </block>
                <action method="addTab">
                    <name>mdg_giftregistry</name>
                    <block>tab_giftregistry_main</block>
                </action>
            </reference>
        </reference>
    </adminhtml_customer_edit>
</layout>

Then finally I added the block and template to the config.xml file

    <blocks>
        <mdg_prime>
            <class>Mdg_Prime_Block</class>
        </mdg_prime>
    </blocks>


<adminhtml>
    <layout>
        <updates>
            <mdg_prime module="mdg_prime">
                <file>giftregistry.xml</file>
            </mdg_prime>
        </updates>
    </layout>
</adminhtml>

Please Kindly help if you can. I have no idea why the ajax loader on the grid won't stop loading. Plus why it disappers too. Thanks

Your Answer

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

Browse other questions tagged or ask your own question.