Grid filters in Magento
Since last few days I am working on a custom admin module, and was required to make a functionality related to Filters.
The functionality was such that I needed to fetch the filters inserted in the Grid, that is if we are searching records with names like ‘john’, so here ‘john’ will be filter.
Now it was bit confusing here, Magento encodes (base64_encode) the filter inserted, so I was not able to find the filters in session directly, but after studying the code and wasting lot of time was able to find the solution at last.
I am writting here the code for fetching the filters, I am taking Orders Grid (Adminend > Sales > Orders) for example.
Please open file app/code/core/Mage/Adminhtml/Block/Sales/Order/Grid.php
Now write the below code in function _prepareCollection
protected function _prepareCollection()
{
$collection = Mage::getResourceModel($this->_getCollectionClass());
$this->setCollection($collection);
//start
$filter = $this->getParam('filter');
$filter_data = Mage::helper('adminhtml')->prepareFilterString($filter);
echo '<pre>';
print_r($filter_data);
echo '</pre>';
//end
return parent::_prepareCollection();
}
Now search records with ‘Bill to Name’ like ‘john’ (or as per your records), and you will be able to get array as shown here (as per your search terms)
Array
(
[created_at] => Array
(
[locale] => en_US
)
[billing_name] => john
)
Note: I am using the default Magento code for the above example, it is recomended to override this grid in local
Hope this helps.

There is a very good extension for custom Orders Grid
http://www.magentocommerce.com/magento-connect/brandammo/extension/7956/ordersgridpro_custom_orders_grid