Moose
Moose

Reputation: 630

How to link to a custom grid with pre-applied filters?

I'm developing a module which uses a custom model to create a grid.

The model has a field 'username' & I would like to generated a hyperlink to the grid with a predefined username filtered, i.e displaying only the entries where the username is Matt.

I can't think of an example whereby the core developers do something along these lines and looking at the URL on the admin page after applying the filter in the username column, I only see session jargon:

/index.php/admin/bookouts/index/key/4ed130b406cd65dc43dd190bb5ae35ec/filter/Ym9va291dF9kYXRlJTVCZnJvbSU1RD0wNCUyRjA5JTJGMjAxMyZib29rb3V0X2RhdGUlNUJ0byU1RD0wNCUyRjA5JTJGMjAxMyZib29rb3V0X2RhdGUlNUJsb2NhbGUlNUQ9ZW5fR0I=/form_key/BQUuqBB4miqqa0Hu/

Would appreciate any input.

Upvotes: 1

Views: 1771

Answers (1)

Marius
Marius

Reputation: 15216

That is not 'session jargon'. It is actually the filter values encoded with base64_encode. So you can generate your URL like this:

$filter = 'username=Jack';
$filter = base64_encode($filter);
$url = Mage::helper('adminhtml')->getUrl('adminhtml/bookouts/index', array('filter'=>$filter));

Upvotes: 11

Related Questions