Completly agree with you, and it's what I've done.
protected function populateState($ordering = null, $direction = null)
{
// Initialise variables.
$app = JFactory::getApplication();
$session = JFactory::getSession();
// Adjust the context to support modal layouts.
if ($layout = JRequest::getVar('layout')) {
$this->context .= '.'.$layout;
}
// for $filter_id_race context never change to conserve filter on each page ...
$filter_id_race = $app->getUserStateFromRequest('filter.id_race', 'filter_id_race');
$this->setState('filter.id_race', $filter_id_race, null, 'int');
.....
$filter_id_statut = $app->getUserStateFromRequest($this->context.'.filter.id_statut', 'filter_id_statut');
$this->setState('filter.id_statut', $filter_id_statut, 2, 'int');
......
parent::populateState();
}
Normaly, if $filter_id_statut is null (meaning no filtered), the default value '2' is setted to 'filter.id_statut', but as I said, it does not work...
Of course I can add a line to test the value of $filter_id_statut like that :
$filter_id_statut = $app->getUserStateFromRequest($this->context.'.filter.id_statut', 'filter_id_statut');
if ( empty($filter_id_statut)) {
$this->setState('filter.id_statut', 2, null, 'int');
} else {
$this->setState('filter.id_statut', $filter_id_statut, null, 'int');
}
it works, but it is not a nomal behaviours, isn't it ?
Marc.