Welcome, Guest
Username: Password: Remember me

TOPIC: reset filter on the server side

reset filter on the server side 19 Jul 2013 08:20 #10524

  • Frederic
  • Frederic's Avatar
  • Offline
  • Senior Member
  • Posts: 56
  • Karma: 0
Hi,

I would like to reset filters of a grid on the PHP side. Is there a tip written somewhere about this ?

Thanks in advance,
Best regards,

Fred
The administrator has disabled public write access.

reset filter on the server side 27 Jul 2013 14:45 #10610

  • Frederic
  • Frederic's Avatar
  • Offline
  • Senior Member
  • Posts: 56
  • Karma: 0
Hi,

I'll appreciate greatly a help on that one...

The idea is to reset the search fields programmaticaly when the user has selected a new category.

In JS, there is the "Joomla.resetFilters();" function. Is there something that can be called in PHP ?

Thanks in advance,
Best,

Fred
The administrator has disabled public write access.

reset filter on the server side 27 Jul 2013 19:09 #10611

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
Some leads :
1°) In the yourview_filters.php, there is a button that uses onclick :
<button onclick="resetFilters()"><?php echo(JText::_("JSEARCH_FILTER_CLEAR")); ?></button>
then jQuery in the same file, you have, at the top
function resetFilters()
2°) In the view.html.php, you have :
$this->filters['name of the filter']->value = $model->getState("filter.name of the filter");
so maybe you could set the value yourself there
Last Edit: 27 Jul 2013 19:10 by VeCrea.
The administrator has disabled public write access.

reset filter on the server side 30 Jul 2013 09:39 #10627

  • Frederic
  • Frederic's Avatar
  • Offline
  • Senior Member
  • Posts: 56
  • Karma: 0
Hi VeCrea,

Thank you for your answer and sugestions.

After complementary analysis, my problem is more linked to a context. It would be nice to be able to flush a filter's view from another view but in this case $this->filter will contains the current filter's view and not the one I would like to fflush... I have to think to a way...

Best,

Fred
The administrator has disabled public write access.

reset filter on the server side 30 Jul 2013 12:21 #10628

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
So, change the context.
$model->set('context', 'another_context');

Context can be any string.

Then, in prepareQuery(), you just have to change few things to filter differently for this context.

You can also use state vars.
$model->setState('myStateVar', true);

Than, check this state var to filter or not.
In few words, do what you want in the prepareQuery() function. But the parameters must be sent through states vars or simply the context.
Coding is now a piece of cake
The administrator has disabled public write access.

reset filter on the server side 31 Jul 2013 14:13 #10647

  • Frederic
  • Frederic's Avatar
  • Offline
  • Senior Member
  • Posts: 56
  • Karma: 0
Thank you admin. I will seach a solution in that direction.

Best regards,

Fred
The administrator has disabled public write access.
Time to create page: 0.075 seconds

Get Started