To apply default filter for the grid view follow the instructions below:
Open your corresponding grid.php file and look for the following
Add the following line of code next to above code
In above code , "featured" is the name of the field and 1 is the default value to be applied to filter. Also you can add any number of filter in the array with in setDefaultFilter function.
Open your corresponding grid.php file and look for the following
protected function _prepareCollection() {
Add the following line of code next to above code
$this->setDefaultFilter(array('featured'=>1));
In above code , "featured" is the name of the field and 1 is the default value to be applied to filter. Also you can add any number of filter in the array with in setDefaultFilter function.
Works perfect.If you need receive filter value from another module do in this way:
ReplyDelete// Example Filter by customer
// 'customer' = the $_GET parameter
// 'customer_id' the grid index value
if ($customer = $this->getRequest()->getParam('customer'))
$this->setDefaultFilter(array('customer_id' => $customer));
This comment has been removed by a blog administrator.
ReplyDeleteThanks for the best blog.it was very useful for me.keep sharing such ideas in the future as well.this was actually what i was looking for,and i am glad to came here!
ReplyDeletemagento development company in bangalore