You were close editing the model files. In your Persons model (ExampleModelPersons) you need to make sure you have the following elements:
Whitelist the filter name:
<?php
public function __construct($config = array())
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = array(
'country',
// other not standard filters
);
}
parent::__construct($config);
}
?>
Autopopulate the state filter:
<?php
protected function populateState($ordering = null, $direction = null)
{
$country = $this->getUserStateFromRequest($this->context.'.filter.country', 'country', '', null, false);
$this->setState('filter.country', (int) $country);
// ....Other states
{
?>
Store id for the context:
<?php
protected function getStoreId($id = '')
{
$id .= ':'.$this->getState('filter.country');
// Other states
}
?>
And the most important one, the database query
<?php
protected function getListQuery()
{
// ... Other parts of the querty
if ($country = $this->getState('filter.country'))
$query->where("country = ". (int) $country);
}
?>
If you don't need saving the state in user's session this can be easily stripped into two liner in the database query.
<?php
// ... Other parts of the querty
if ($country = $app->input->getInt('country'))
$query->where("country = ". (int) $country);
?>