我们如何从管理员客户编辑视图添加数据库表的自定义网格?

时间:2013-04-10 04:59:29

标签: magento gridview block

我在客户编辑标签中添加了自定义新标签。我想在新标签点击时添加网格视图。 我已经创建了一个自定义模块,用于向数据库表添加数据。我该如何使用该控制器来获取我的阻止。

我正在使用下面的文件。任何人都可以帮我加载网格视图作为按钮点击操作。?

require_once("Mage/Adminhtml/Block/Customer/Edit/Tabs.php");
class Proporta_Warrenty_Block_Adminhtml_Customer_Edit_Tabs extends Mage_Adminhtml_Block_Customer_Edit_Tabs {

    private $parent;



    public function _construct() {
        die('came to die');
    }

    protected function _prepareLayout() {


        ///get all existing tabs.
        $this->parent = parent::_prepareLayout();


        ///if the module is enabled, add new tab.
        if (Mage::helper('core')->isModuleEnabled('Proporta_Warrenty') ) {
            $this->addTab('warrenty', array(
                'label' => Mage::helper('customer')->__('Proporta Warrenty'),
               // 'content' => 'test sanjeeeee',
                'content' => $this->getLayout()->createBlock('warrenty/adminhtml_tab_grid')->toHtml() ,
            ));
        }

        return $this->parent;
    }

}

这是网格文件

<?php
class Proporta_Warrenty_Block_Adminhtml_Warrenty_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
  public function __construct()
  {
    parent::__construct();
    $this->setSaveParametersInSession(true);

  }

  protected function _prepareCollection()
  {
    $session_customer_id = Mage::getSingleton('customer/session')->getCustomer()->getId();
    $collection = Mage::getModel('warrenty/warrenty')->getCollection($session_customer_id);
    $this->setCollection($collection);
    return parent::_prepareCollection();
  }

  protected function _prepareColumns()
  {
   $this->addColumn('entity_id', array(
        'header'    => Mage::helper('warrenty')->__('Entity Id'),
        'align'     =>'left',
        'index'     => 'increment_id',
    ));

    $this->addColumn('product_id', array(
        'header'    => Mage::helper('warrenty')->__('Product Name'),
        'align'     =>'left',

    ));  
    $this->addColumn('product_barcode', array(
        'header'    => Mage::helper('warrenty')->__('Product Barcode'),
        'align'     =>'left',

    )); 

        $this->addColumn('registered_at', array(
        'header'    => Mage::helper('warrenty')->__('Registered Date'),
        'align'     =>'left',
        'index'     => 'registered_at',
        'type'      => 'datetime'   ,
    ));

    $this->addExportType('*/*/exportCsv', Mage::helper('warrenty')->__('CSV'));
    $this->addExportType('*/*/exportXml', Mage::helper('warrenty')->__('XML'));

    return parent::_prepareColumns();
  }


}

这是模板中的标签文件

<li >
        <a href="" 
           id="customer_info_tabs_orders" 
           name="warrenty" title="Warranty"
           class="tab-item-link ajax notloaded">
            <span>
                <span class="changed" title="<?php echo $this->__('The information in this tab has been changed.') ?>"></span>
                <span class="error" title="<?php echo $this->__('This tab contains invalid data. Please solve the problem before saving.') ?>">
                </span><?php echo 'Proporta Warrenty'; ?></span>
        </a>
        <div id="customer_info_tabs_warrenty_content" style="display:none;"></div>
    </li>

这是config xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<config>
    <stores>
        <admin>
            <design>
                <theme>
                    <default>proporta</default>
                </theme>
            </design>
        </admin>    
    </stores>

    <modules>
        <Proporta_Warrenty> 
            <version>0.1.0</version>
            <depends>
                <!-- no dependencies --> 
            </depends>
        </Proporta_Warrenty> 
    </modules> 

    <global>
        <helpers>
            <warrenty>
                <class>Proporta_Warrenty_Helper</class>
            </warrenty>
        </helpers>

        <template>
            <email>
                <custom_order_tpl module="Proporta_Warrenty">
                    <label>Life time Warranty</label>
                    <file>lifeTimeWarranty.html</file>
                    <type>html</type>
                </custom_order_tpl>
            </email>
        </template>
    </global>

    <frontend>
        <routers>
            <warrenty>
                <use>standard</use>
                <args>
                    <module>Proporta_Warrenty</module>
                    <frontName>warrenty</frontName>
                </args>
            </warrenty>
        </routers>
        <events></events> 
        <translate>
            <modules>
                <Proporta_Warrenty>
                    <files>
                        <default>Proporta_Warrenty.csv</default>
                    </files>
                </Proporta_Warrenty>
            </modules>
        </translate> 
        <layout>
        </layout>
    </frontend>

    <adminhtml>
        <routers>
            <warrenty>
                <use>standard</use>
                <args>
                    <module>Proporta_Warrenty</module>
                    <frontName>warrenty</frontName>
                </args>
            </warrenty>
        </routers>
    </adminhtml> 



</config>

任何人都可以帮我添加标签操作,如上面的网格视图一样吗?

0 个答案:

没有答案