2011-08-03 6 views
6

मैं इस गाइड Custom Module with Custom Database TableMagento adminhtml कस्टम मॉड्यूल यह ग्रिड दिखा रहा है दो बार

मैं पहले से ही लागू कर दिया है मेरी बैकएंड adminhtml के लिए मॉड्यूल अस्तित्व में पालन करके Magento के लिए नया हूँ। मैं डेटाबेस से सामान ले रहा हूं और adminhtml पेज पर stowing ot। सब कुछ ठीक काम करता है सिवाय इसके कि मैं adminhtml पर ग्रिड दो बार प्राप्त कर रहा हूं। मुझे दो बार एक ही ग्रिड मिल रहा है। मैंने कोड को 2 घंटों के लिए देखा है, इसे समझ नहीं सकता है। अगर कोई जानता है कि इस समस्या को कैसे ठीक किया जाए तो मैं बहुत थकाऊ होगा। चियर्स

मेरी 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())); 
}} 

से कोड thats और इस indexAction समारोह

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

ग्रिड कंटेनर डिस्कवर करें या ग्रिड कंटेनर और लेआउट.एक्सएमएल के साथ अपना प्रश्न अपडेट करें। – azakolyukin

उत्तर

1

सुनिश्चित करें कि ग्रिड ब्लॉक पहले से ही इसी लेआउट में लोड नहीं है बनाने के नियंत्रक से है .xml फ़ाइल।

3

मैं इसे तय की। मुझे केवल

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

इंडेक्स एक्शन से मुझे लगता है कि मैं इसे दो बार लोड कर रहा हूं।

+2

आपको अन्य लोगों को ढूंढना आसान बनाने के लिए शायद इस उत्तर को स्वीकार करना चाहिए। –

6

शायद तुम लेआउट में यह डालने कर रहे हैं, में

adminhtml> डिफ़ॉल्ट> डिफ़ॉल्ट> लेआउट pricenotify.xml की जाँच करें।

जैसे:

<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> 

इस ब्लॉक निकालें या टिप्पणी लाइन जहाँ आप सामग्री जोड़ें।

0

खैर मैं एक ही मुद्दे का सामना करना पड़ रहा था लेकिन मेरे मामले में यह कारण $this->setId('messages'); लाइन (अपने Grid.php निर्माण में) था। क्योंकि Magento पहले से ही <div id="messages"></div> अपने ग्रिड पेज (नोटिफिकेशन दिखाने के लिए) में है, जिसके कारण मेरी ग्रिड सामग्री इस 'div' टैग में लोड हो रही थी इसलिए ग्रिड को दो बार दिखा रहा था। तो सबक सीखा है कि ग्रिड.एफ़पी में अपना 'आईडी' सेट करते समय सामान्य नाम न दें जो पहले से ही ग्रिड पेज में मौजूद हो सकता है।

0

मेरे मामले में, यह संपादन/फार्म पर हुआ, और मैं अपने Adminhtml नियंत्रक पर अनजाने renderLayout() दोहराया गया था।

$this->renderLayout(); 
संबंधित मुद्दे