Smart Search Filter Results

Brad Chapman asked on March 16, 2016 23:40

Hey There Silly question probably - How does one retrieve the smart search filter term after post back? For example: "Results are currently filtered by: {smart search filter result here}" The natural thing would to just use some JavaScript but is there a macro solution for this? Cheers, Brad

Correct Answer

Trevor Fayas answered on March 17, 2016 05:46

You may need to do some adjustments then. Try cloning the filter web part (including cloning the ascx) and modifying it to add a literal control that will render the values out in a hidden tag for you to grab with JavaScript.

I don't think there exists any in house solution.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Trevor Fayas answered on March 17, 2016 01:45

Are you talking about what they search for, or an actual Smart Search Filter webpart you are attaching to your smart search?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on March 17, 2016 01:58

Typically it is added to the URL as a query string. So you should be able to use a macro or C# to get the value.

{% QueryString.GetValue("searchtext") #%}

If you're using an actual filter it might be a bit more difficult as you would need access to those filters.

1 votesVote for this answer Mark as a Correct answer

Brad Chapman answered on March 17, 2016 05:35 (last edited on March 17, 2016 05:36)

Thanks guys. Yes it's a smart search filter so there is no actual query string. I believe these are passed though as form variables in the viewstate. I've had a look through the available macro objects and there is nothing obvious that looks like it is containing the data. I've also tried the javascript option but the form controls rendered ID doesn't appear to resolve as a DOM object; the traditional GetElementByID path returns NULL.

0 votesVote for this answer Mark as a Correct answer

Brad Chapman answered on March 23, 2016 03:59

I've dropped the requirement for the moment. I may end up using your suggestion Trevor but am trying to avoid any customisations of the code base.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.