Note that there are some explanatory texts on larger screens.

plurals
  1. POcan i use multiple grids in magento module?
    primarykey
    data
    text
    <p>Can i use multiple grids in one magento module?</p> <pre><code>&lt;?php class &lt;Namespace&gt;_&lt;Module&gt;_Block_Adminhtml_&lt;Module&gt; extends Mage_Adminhtml_Block_Widget_Grid_Container { public function __construct() { $this-&gt;_controller = 'adminhtml_&lt;module&gt;'; $this-&gt;_blockGroup = '&lt;module&gt;'; $this-&gt;_headerText = Mage::helper('&lt;module&gt;')-&gt;__('Item Manager'); $this-&gt;_addButtonLabel = Mage::helper('&lt;module&gt;')-&gt;__('Add Item'); parent::__construct(); } } </code></pre> <p>so i can create one grid if i am bounded to use module, which means that grid is heavily dependent on module, so how can we use multiple grids in same module? I can't find the way, plz guide me. </p> <p>I am getting errors in my attempt to keep it move on. I am describing it more</p> <p>My Grid Container</p> <pre><code>class World_Exporter_Block_Adminhtml_Import extends Mage_Adminhtml_Block_Widget_Grid_Container{ public function __construct() { // Correction made on getting answer $this-&gt;_controller = 'adminhtml_import'; $this-&gt;_blockGroup = 'exporter'; // Correction made on getting answer $this-&gt;_headerText = Mage::helper('exporter')-&gt;__('Item Manager'); $this-&gt;_addButtonLabel = Mage::helper('exporter')-&gt;__('Add Item'); } } </code></pre> <p>And My Grid</p> <pre><code>class World_Exporter_Block_Adminhtml_Import_Grid extends Mage_Adminhtml_Block_Widget_Grid{ public function __construct(){ parent::__construct(); $this-&gt;setId('imports'); $this-&gt;setSaveParametersInSession(false); // As it was not calling prepareCollection() I explicitly call it $this-&gt;_prepareCollection(); } protected function _prepareCollection(){ $collection = Mage::getModel('exporter/imports')-&gt;getCollection(); $this-&gt;setCollection($collection); return parent::_prepareCollection(); } protected function _prepareColumns(){ // return false; $this-&gt;addColumn('import_id ', array( 'header' =&gt; Mage::helper('exporter')-&gt;__('ID'), 'align' =&gt; 'right', 'width' =&gt; '50px', 'index' =&gt; 'import_id ', )); $this-&gt;addColumn('import_file', array( 'header' =&gt; Mage::helper('exporter')-&gt;__('File Name'), 'align' =&gt; 'left', 'index' =&gt; 'import_file', )); $this-&gt;addColumn('import_time', array( 'header' =&gt; Mage::helper('exporter')-&gt;__('Import Time'), 'align' =&gt; 'left', 'index' =&gt; 'import_time', )); $this-&gt;addColumn('profile_id', array( 'header' =&gt; Mage::helper('exporter')-&gt;__('Profile'), 'align' =&gt; 'left', 'index' =&gt; 'profile_id', )); return parent::_prepareColumns(); } protected function _prepareMassaction(){ $this-&gt;setMassactionIdField('import_id'); $this-&gt;getMassactionBlock()-&gt;setFormFieldName('imports'); return $this; } } </code></pre> <p>My Controller</p> <pre><code>class World_Exporter_Adminhtml_ExporterController extends Mage_Adminhtml_Controller_action{ public function importAction(){ $this-&gt;_initAction(); $this-&gt;_addContent($this-&gt;getLayout()-&gt;createBlock('exporter/adminhtml_import')); $this-&gt;renderLayout(); } } </code></pre> <p>My confix xml chunk</p> <pre><code>&lt;models&gt; &lt;exporter&gt; &lt;class&gt;World_Exporter_Model&lt;/class&gt; &lt;resourceModel&gt;exporter_mysql4&lt;/resourceModel&gt; &lt;/exporter&gt; &lt;exporter_mysql4&gt; &lt;class&gt;World_Exporter_Model_Mysql4&lt;/class&gt; &lt;!-- declate table test --&gt; &lt;entities&gt; &lt;profiles&gt; &lt;table&gt;profiles&lt;/table&gt; &lt;/profiles&gt; &lt;imports&gt; &lt;table&gt;imports&lt;/table&gt; &lt;/imports&gt; &lt;columns&gt; &lt;table&gt;columns&lt;/table&gt; &lt;/columns&gt; &lt;/entities&gt; &lt;!-- -/- --&gt; &lt;/exporter_mysql4&gt; &lt;/models&gt; </code></pre> <p>My model</p> <pre><code> class World_Exporter_Model_Imports extends Mage_Core_Model_Abstract { public function _construct() { $this-&gt;_init('exporter/imports'); } } </code></pre> <p>Mysql4 Model</p> <pre><code> class World_Exporter_Model_Mysql4_Imports extends Mage_Core_Model_Mysql4_Abstract { public function _construct() { $this-&gt;_init('exporter/imports', 'import_id'); } } </code></pre> <p>My collection</p> <pre><code> class World_Exporter_Model_Mysql4_Imports_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract { public function _construct(){ parent::_construct(); $this-&gt;_init('exporter/imports'); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload