I created grid and custom form admin side. when i press on row it will open the form and there is one button for reset i click on it, it won't work. i tried to set action in controller and other thing but it not work.

and other problem is that in grid when i search data from particular column it reset whole page and display answer but i want to get output through ajax so, that page will not refresh. How can i set ajax code?


Regarding the Ajax grids

You need to:

Update thanks to the comment of Richard Parnaby-King:
I forgot to mention this: set the use_ajax property of the grid block to true:


This can be done in the _construct() method.

Then implement the method getGridUrl() on your grid block to return the Ajax request URL

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

Then you need to create the controller action method to process the Ajax request. It's simple, it only needs to instantiate and render the grid block. You can do that either via $this->loadLayout(false)->renderLayout() and add the grid block via layout XML, or instantiate and render it using PHP:


Thats all. To summarize, there are three steps:

  1. Implement the getGridUrl() method
  2. Implement the controller grid url action
  3. Render (only) the grid block

Regarding the Reset Button

The reset button should trigger a page reload via the JavaScript setLocation(window.location.href).

It's added in the constructor of the class Mage_Adminhtml_Block_Widget_Form_Container.

$this->_addButton('reset', array(
    'label'     => Mage::helper('adminhtml')->__('Reset'),
    'onclick'   => 'setLocation(window.location.href)',
), -1);

If it doesn't work, it's probably because some other customization of yours breaks JavaScript execution. To simply get rid of the button you could place a $this->removeButton('reset') into the _prepareLayout() method of your form container.

| improve this answer | |
  • I am also interested in making my grids ajax, but my code already has the above in it. – Richard Parnaby-King Jul 17 '13 at 10:30
  • 1
    Whoo - got the ajax working. In the grid block constructor, add $this->setUseAjax(true);. – Richard Parnaby-King Jul 17 '13 at 11:02
  • ok, Thanks Vinai. Can you help me for reset button? – MageDev Jul 17 '13 at 12:50
  • Updated the answer to address the reset button issue, too. – Vinai Jul 17 '13 at 13:35
  • it shows invalid method. a:5:{i:0;s:107:"Invalid method Xyz_Example_Block_Adminhtml_Data_Detail_Grid::removeButton(Array ( [0] => reset ) – MageDev Jul 18 '13 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.