• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Dynamic Filtering form based on condition Angular 7 + Spring Boot (Like Amazon Sidebar Filtering)

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am deloping an ecommerce using Angular 7 and Spring boot and i need to add a special feauture. The idea is ,when you are seeing the products you have in the left some filters you could apply to your search. But,those filters should change if the user select another category inside a dropdown. So if the user select "Clothes" ,you will see filters related to "Clothes" category. This is the same way that Amazon shows you the filters you can apply to your category. I dont know which is the best option to do this:

Option 1: In Angular ,i can create Dynamic Form,so when user changes the Category,the correct form will be shown. When user click the search button,inside Spring ,i should read each parameter and add that condition to my query. The bad thing (i Think),it s in this way i can not work with the FilterID and i should use the name of the filter i am deciding inside Angular Form inside the backend. Let me clarify that point:

For Example ,from Angular i have a harcoded Form and those fields (filters for me) have names i created ,so when user clicks search, i will query to the backend something like this "?q=used=true" ,then in the backend,i should check if that condition exist ,then my query will have something like this "and (filter.name ="used" and filter.name=true) or...more filters) In this way,when same parameter name changes from one side or other,it could lead to problems.

Option 2 When user change the dropdown i could make a call to the backend and get the filters related to that category,they will be return in same way i know if for each of them i should draw a textbox,a dropdown,etc. So,with this returned data ,i could create a dynamic form. Now,the question is,when the user click search ,how the data should be passed to the backend? "q?=idFilter=true&idFilter=='red;" ??

Option 3 ?Option 4? Here is another example from another platform:

https://www.despegar.com.ar/autos/c-bue/alquiler-de-autos-en-buenos+aires?filter_number_of_passengers=4,7&filter_promotion=ANY&sorting=RECOMMENDED#/results (In that platform you can buy tickets for Travel,Rent Cars,and a lot of things)

This is maybe the same i want to do,in the link i added above,if you visit it,you will see in the left ,the filters you have in the URL ,applied. But as you can see,if you add filters,the will be added to the URL with custom names.

So ,are they implementing the Option number 1? They create some custom filters names ,for example "filter_number_of_passengers",will be sent when someone add that filter,and then the backend should extract that exact filter ,and then perform the sql query by name?What do you think?

I would really appreciate a help on how to solve this situation.
 
Do not meddle in the affairs of dragons - for you are crunchy and good with ketchup. Crunchy tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic