Jump to:

22972 Posts in 11596 Topics by 2824 members

General Questions

SilverStripe Forums » General Questions » Start custom filter automatically

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 137 Views
  • Bereusei
    Avatar
    Community Member
    94 Posts

    Start custom filter automatically Link to this post

    Hey guys,

    in the backend of SS3 we have the nice filter function to search for special dataobjects in the listview.
    In the modeladmin I´ve used a code which load values in the filter inputfields:

    public function getSearchContext() {
       $currentUser = Member::currentUser()->FirstName;
       $currentUser = trim($currentUser);
          
       $context = parent::getSearchContext();
    $context->getFields()->fieldByName('q[Member__FirstName]')->setValue($currentUser); //set current user name in inputfield 'Member'

    return $context;
    }

    This works pretty fine. What I now wanna do is to start the filter function automatically without clicking the apply-filter-button.
    If have tried to use a javascript to submit the button, but this has the result, that the page is reloading again, again and again.
    Does anybody have an idea to fix this problem? Is there a nice php-function or something else?

    137 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.