2

In My Custom Module, In Admin Grid Reset Filter And Search Button Not Working.

Here Is My Grid.php Code.

C:\xampp2\htdocs\testmagento\app\code\local\Sigmasolve\Makemodel\Block\Adminhtml\Makemodel\Grid.php

<?php

class Sigmasolve_Makemodel_Block_Adminhtml_Makemodel_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct()
    {
        parent::__construct();
        $this->setId('makemodelGrid');
        // This is the primary key of the database
        $this->setDefaultSort('id');
        $this->setDefaultDir('ASC');
        $this->setSaveParametersInSession(true);
        $this->setUseAjax(true);
    }

    protected function _prepareMassaction()
    {
        $this->setMassactionIdField('id');
        $this->getMassactionBlock()->setFormFieldName('makemodel');

        $this->getMassactionBlock()->addItem('delete', array(
             'label'    => Mage::helper('makemodel')->__('Delete'),
             'url'      => $this->getUrl('*/*/massDelete', array('' => '')),
             'confirm'  => Mage::helper('makemodel')->__('Are you sure?')
        ));

       //$statuses = Mage::getSingleton('makemodel/status')->getOptionArray();

        // array_unshift($statuses, array('label'=>'', 'value'=>''));
        // $this->getMassactionBlock()->addItem('status', array(
             // 'label'=> Mage::helper('makemodel')->__('Change status'),
             // 'url'  => $this->getUrl('*/*/massStatus', array('_current'=>true)),
             // 'additional' => array(
                    // 'visibility' => array(
                         // 'name' => 'status',
                         // 'type' => 'select',
                         // 'class' => 'required-entry',
                         // 'label' => Mage::helper('makemodel')->__('Status'),
                         // 'values' => $statuse 
                    //)
                 //)
        // ));
        return $this;
    }

    protected function _prepareCollection()
    {
        $collection = Mage::getModel('makemodel/makemodel')->getCollection();
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }

    protected function _prepareColumns()
    {
        $this->addColumn('id', array(
            'header'    => Mage::helper('makemodel')->__('ID'),
            'align'     =>'right',
            'width'     => '50px',
            'index'     => 'id',  
        ));

        $this->addColumn('ktyp', array(
            'header'    => Mage::helper('makemodel')->__('Ktyp'),
            'align'     =>'left',
            'index'     => 'ktyp',
        ));

        $this->addColumn('manufacturer', array(
            'header'    => Mage::helper('makemodel')->__('Manufacturer'),
            'align'     =>'left',
            'index'     => 'manufacturer',
        ));

        $this->addColumn('model', array(
            'header'    => Mage::helper('makemodel')->__('Model'),
            'align'     =>'left',
            'index'     => 'model',
        ));

        $this->addColumn('capacity', array(
            'header'    => Mage::helper('makemodel')->__('Capacity'),
            'align'     =>'left',
            'index'     => 'capacity',
        ));

        $this->addColumn('year_from', array(
            'header'    => Mage::helper('makemodel')->__('Year_From'),
            'align'     =>'left',
            'index'     => 'year_from',
        ));

        $this->addColumn('year_to', array(
            'header'    => Mage::helper('makemodel')->__('Year_To'),
            'align'     =>'left',
            'index'     => 'year_to',
        ));

        $this->addColumn('fuel', array(
            'header'    => Mage::helper('makemodel')->__('Fuel'),
            'align'     =>'left',
            'index'     => 'fuel',
        ));



        return parent::_prepareColumns();
    }



    public function getRowUrl($row)
    {
        return $this->getUrl('*/*/edit', array('id' => $row->getId()));
    }

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

    }

}

enter image description here

When I Click Reset Filter Or Search Button It Is Go To Front End

enter image description here

enter image description here

2 Answers 2

2

I Found My Mistake. I Forgot Write Code in My Controller File.

public function gridAction()
    {
        $this->loadLayout();
        $this->getResponse()->setBody(
            $this->getLayout()->createBlock('makemodel/adminhtml_makemodel_grid')->toHtml()
        );
    }

So, that's why Code is not working. Thanks for Help...

1
  • Please accept your answer so as the question doesn't pop up randomly some months from now. Jan 17, 2017 at 8:26
1

You can Try this in your Grid.php File :

public function __construct()
{
    parent::__construct();
    $this->setId('makemodelGrid');
    // This is the primary key of the database
    $this->setDefaultSort('id');
    $this->setDefaultDir('ASC');
    $this->setUseAjax(true);
}
3
  • i Have Already Tried it, it is not working Jan 17, 2017 at 7:09
  • Add this line $this->setSaveParametersInSession(false); above $this->setUseAjax(true); Jan 17, 2017 at 7:15
  • it is also not working Jan 17, 2017 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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