Magento Forum

Setting an ajax grid (using $this->setUseAjax(true);)
 
Brandlive_br
Guru
 
Avatar
Total Posts:  653
Joined:  2008-05-19
Buenos Aires, Argentina
 

I got a simple grid, like any module.
I’m trying with $this->setUseAjax(true);

public function __construct()
  
{
      parent
::__construct();
      
$this->setId('weddingsGrid');
      
$this->setDefaultSort('bride_last_name');
      
$this->setDefaultDir('ASC');
      
$this->setDefaultFilter(array('status'=>0));
      
$this->setSaveParametersInSession(true);
      
$this->setUseAjax(true);
  
}

The grid starts to search, and get some result, but never ends the process and I get a broken page.
I let you an image with the efect/problem.

Image Attachments
grid-ajax-search.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
alkarim
Guru
 
Total Posts:  368
Joined:  2008-04-10
 

hi, I got the same problem either…

I wish anyone could figure it out… I’ve tried but I got no clue

 
Magento Community Magento Community
Magento Community
Magento Community
 
AndreusPT
Jr. Member
 
Total Posts:  15
Joined:  2008-07-25
 

well, it looks like the same URL is being requested by ajax, instead of an action for just a grid block.

I’m looking at the product grid controller action and grid block:

in the grid block there’s:

public function getGridUrl()
    
{
        
return $this->getUrl('*/*/grid', array('_current'=>true));
    
}

and in the controller there’s an action

/**
     * Product grid for AJAX request
     */
    public function gridAction()
    
{
        $this
->getResponse()->setBody(
            
$this->getLayout()->createBlock('adminhtml/catalog_product_grid')->toHtml()
        );
    
}
and replace block type with your grid block type.

will it work?

 
Magento Community Magento Community
Magento Community
Magento Community
 
alkarim
Guru
 
Total Posts:  368
Joined:  2008-04-10
 

thanks, It will works…

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brandlive_br
Guru
 
Avatar
Total Posts:  653
Joined:  2008-05-19
Buenos Aires, Argentina
 

This tip helps. Now I’m getting troubles with this example.
I’m using a grid inside an editable tab.
I’m gonna make more tests and post the result.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brandlive_br
Guru
 
Avatar
Total Posts:  653
Joined:  2008-05-19
Buenos Aires, Argentina
 

I’m trying this, but I get this error:

Call to a member function toHtml() on a non-object.

Any idea?

 
Magento Community Magento Community
Magento Community
Magento Community
 
kdtips
Member
 
Avatar
Total Posts:  73
Joined:  2011-08-13
Auckland New Zealand
 

I had an extension

LOOK AT HERE

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top