Two drop down smart filters with dependancy

paul carter asked on November 26, 2019 09:14

Hi i have just built 2 smart drop down filters. my first drop down lists categories under a specific parent. I am looking at the second drop down displaying the sub categories of the chosen parent from the first. What is the best way to get information regarding the parent from the first drop down so i may build a query listing the sub categories

Recent Answers


Roman Hutnyk answered on November 26, 2019 13:09

You need to share select value of the first drop down with the second one. The easiest (not saying it is the best) way to share it would be trough query string. Then you will need to use the value from query string in where condition of the second filter. E.g.:

  • first drop down on selected value change does postback and adds query parameter let's say 'category'
  • second drop down uses 'category' parameter in where condition: ParentCategoryID = {% category %}

See more details here: https://docs.kentico.com/k12/e-commerce-features/configuring-on-line-stores/configuring-product-pages/configuring-product-listings-with-filtering#Configuringproductlistingswithfiltering-Placingthefilterwebpart

1 votesVote for this answer Mark as a Correct answer

paul carter answered on November 26, 2019 14:23

Hi, Thanks for the reply. I have actually been looking at building a custom macro, and retrieving session variable> I shall try that first and look at your option if i struggle. Whats your thoughts? My only issue i tried using the example from the net but for some reason i am not seeing the macro in the macro console. I noticed in the only versions it discussed also having to use the moduleloader, but that is apparently deprecated, so assuming i don't require that anymore. Any suggestions? regards..

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on November 26, 2019 14:34

Are you using custom filter or out of the box? if out of the box one - I doubt its value is stored into a session. In case you're using custom one you might want to consider component events on one hand, but on another hand with custom control you might place both drop downs into your control and have easy access to their values.

0 votesVote for this answer Mark as a Correct answer

paul carter answered on November 26, 2019 14:40

im using standard dropdown smart filters.I was under the impression that i could get the session variables from these web parts, as they use postback ?

0 votesVote for this answer Mark as a Correct answer

paul carter answered on November 26, 2019 14:59

Also i understand the logic of the query parameter from the first drop down. Just not sure how to access it, hence the idea of session variables ..

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on November 26, 2019 15:03

Indeed they use postback, but postback does not store form data sent within it into the session

0 votesVote for this answer Mark as a Correct answer

paul carter answered on November 26, 2019 15:13

Ok, Understood, so how can i get access to the resulting query string from the first drop down ?

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on November 26, 2019 15:48

I believe you should be able to configure smart drop down filter web part to add its value to the URL. Once that works just get it with macro and use for where condition in the second drop down, e.g.: ParentCategoryID = {% category %}

0 votesVote for this answer Mark as a Correct answer

paul carter answered on November 27, 2019 09:27

Not too sure how to add the value to the URL in the smart search filter . is it documented.If this doesn't work maybe i'm best going with a cloned smart filter with two drop downs and a where clause ?. Obviously would prefer to go with the quicker solution in the short term with a possible long term of creating the custom filter. Regards

0 votesVote for this answer Mark as a Correct answer

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