2011-08-03 17 views
6

soy nuevo en Magento siguiendo esta guía Custom Module with Custom Database TableMagento módulo personalizado adminhtml se muestra la rejilla doble

he aplicado a mi ya existían módulo al adminhtml backend. Estoy tomando cosas de la base de datos y escribiendo ot en la página de administración. Todo funciona bien, excepto que estoy obteniendo la cuadrícula dos veces en el adminhtml. Estoy obteniendo la misma Grilla dos veces. Miré el código por 2 horas y no puedo entenderlo. si alguien sabe cómo solucionar este problema, lo haré muchísimo. aplausos

eso es el código de mi grid.php

<?php 

     class Ecom_Pricenotify_Block_Adminhtml_Pricenotify_Grid extends Mage_Adminhtml_Block_Widget_Grid{ 
public function __construct() 
{ 
    parent::__construct(); 
    $this->setId('pricenotifyGrid'); 
    // This is the primary key of the database 
    $this->setDefaultSort('pricenotify_id'); 
    $this->setDefaultDir('ASC'); 
    $this->setSaveParametersInSession(true); 
} 

protected function _prepareCollection() 
{ 
    $collection = Mage::getModel('pricenotify/pricenotify')->getCollection(); 
    $this->setCollection($collection); 
    return parent::_prepareCollection(); 
} 

protected function _prepareColumns() 
{ 
    $this->addColumn('pricenotify_id', array(
     'header' => Mage::helper('pricenotify')->__('Notification ID'), 
     'align'  =>'left', 
     'width'  => '50px', 
     'index'  => 'pricenotify_id', 
    )); 

    $this->addColumn('prod_id', array(
     'header' => Mage::helper('pricenotify')->__('Product ID'), 
     'align'  =>'left', 
     'width'  => '50px', 
     'index'  => 'prod_id', 
    )); 


    $this->addColumn('prod_price', array(
     'header' => Mage::helper('pricenotify')->__('Product Price'), 
     'align'  =>'left', 
     'width'  => '50px', 
     'index'  => 'prod_price', 
    )); 

    $this->addColumn('user_price', array(
     'header' => Mage::helper('pricenotify')->__('User Price'), 
     'align'  =>'left', 
     'width'  => '50px', 
     'index'  => 'user_price', 
    )); 

    $this->addColumn('email', array(
     'header' => Mage::helper('pricenotify')->__('E-Mail Address'), 
     'align'  =>'left', 
     'width'  => '150px', 
     'index'  => 'email', 
    )); 

    $this->addColumn('created_time', array(
     'header' => Mage::helper('pricenotify')->__('Creation Time'), 
     'align'  => 'left', 
     'width'  => '120px', 
     'type'  => 'date', 
     'default' => '--', 
     'index'  => 'created_time', 
    )); 


    $this->addColumn('status', array(

     'header' => Mage::helper('pricenotify')->__('Status'), 
     'align'  => 'left', 
     'width'  => '80px', 
     'index'  => 'status', 
     'type'  => 'options', 
     'options' => array(
      'success' => 'Inactive', 
      'pending' => 'Active', 
     ), 
    )); 

    return parent::_prepareColumns(); 
} 

public function getRowUrl($row) 
{ 
    return $this->getUrl('*/*/edit', array('id' => $row->getId())); 
}} 

y esta función es indexAction desde el controlador

public function indexAction() { 
    $this->_initAction();  
    $this->_addContent($this->getLayout()->createBlock('pricenotify/adminhtml_pricenotify')); 
    $this->renderLayout(); 
    } 
+0

Descubre el contenedor de cuadrícula o actualiza tu pregunta con el contenedor de cuadrícula y layout.xml. – azakolyukin

Respuesta

1

asegurarse de que el bloque de la rejilla no se ha cargado en la disposición correspondiente archivo .xml

3

Lo arreglé. solo tuve que comentar

//$this->_addContent($this->getLayout()->createBlock('pricenotify/adminhtml_pricenotify')); 

de indexAction Supongo que estaba cargando dos veces.

+2

Probablemente acepte esta respuesta para que otras personas la encuentren más fácilmente. –

6

Tal vez usted es insertarlo en el diseño, compruebe pricenotify.xml en

adminhtml> default> default> diseño.

Tales como:

<pricenotify_adminhtml_manager_pricenotify> 
     <block type="core/text_list" name="root" output="toHtml"> 
      <block type="pricenotify/adminhtml_pricenotify_grid" name="pricenotify.grid"/> 
     </block> 
    </pricenotify_adminhtml_manager_pricenotify> 

Quitar este bloque o comentar la línea donde se agrega el contenido.

0

Bueno, yo estaba enfrentando el mismo problema, pero en mi caso se debió a la línea $this->setId('messages'); (en su construcción Grid.php). Porque magento ya tiene el mismo <div id="messages"></div> en su página de cuadrícula (para mostrar notificaciones) debido a que el contenido de mi cuadrícula se estaba cargando dentro de esta etiqueta 'div' mostrando la cuadrícula dos veces. Entonces, la lección aprendida es no dar un nombre general al configurar su 'id' en Grid.php, que ya podría estar presente en la página de la grilla.

0

En mi caso, sucedió en Editar/Formularios, y he duplicado involuntariamente renderizar() en mi controlador Adminhtml.

$this->renderLayout(); 
Cuestiones relacionadas