Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

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

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

Please Log in or Create an account to join the conversation.

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

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

Please Log in or Create an account to join the conversation.

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

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
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

Please Log in or Create an account to join the conversation.

Last edit: by VeCrea.

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

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

Please Log in or Create an account to join the conversation.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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

Please Log in or Create an account to join the conversation.

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

Thank you admin. I will seach a solution in that direction.

Best regards,

Fred

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.070 seconds

  Excellent Tool ! This tool will save you a lot of time writing the same old structure. I've used others but this is really nice for a quick start. Makes a 3 hour task a 15 minute one. Thanks for this extension
dickrundell (JED)
         

Get Started