Grid doesn't appear in custom admin module in Magento

后端 未结 3 1088
轻奢々
轻奢々 2021-01-19 03:23

I am trying to create a custom module in magento admin. I have reached the point where a new link has been added to the menu and by clicking on it, I can navigate to the ind

3条回答
  •  青春惊慌失措
    2021-01-19 04:08

    Looks like you have the grid blocks set up correctly. However, you still need to load the grid into the layout and render it. This can either be done in the adminhtml layout xml or in the controller.

    In your /app/design/adminhtml/../layout/brands.xml:

        
    
            
                
                    
                
            
    
    

    In your controller:

    public function indexAction()
    {
        $this->loadLayout();
        $this->_addContent(
            $this->getLayout()->createBlock('brands/brands_grid','brands')
        );
        $this->renderLayout();
    }
    

    Please note that you have to modify the above to your particular implementation. I think the layout xml is harder to comprehend initially than the programmatic instantiation in the controller, however, in the long run, it leads to less code bloat.

提交回复
热议问题