❔ I would like to use an SQL query on a consecutive Select HTML element.
I have this form were I can add a product, a Product is made with this structure:
But in the creation form i pass a ViewModel
ProductVM
, which contains a SelectListItem
with all Categories and SubCategories.
So each SubCategory
element contains a foreign key to a Category
element.
I have a Create.cshtml
view for the Products, I would like to apply some filtering, but I have no idea how to do it, since I should send back and forward data from View to Controller multiple times.
I would like to :
- Display all the categories in a HTML Select at the start while the Select for the SubCategories is disabled.
- Once I've selected the Category, I want to enable the SubCategories Select and show only the SubCategories which contains the previously selected CategoryId.
Yesterday I tried my best to implement this logic, but I feel like I'm missing some pieces.
The ViewModel of the Product:
Could you help me please?4 Replies
what framework are we using here?
ASP .NET, by the way I solved!
Executed this JS script on my GET rest API
GET API
great
that is definitely the way to do it, if you are okay with JS
if there's not TOO many categories, you could also just fetch them all up-front, and group them, and only use JS to pick out which group to show, at any given time
so, no server/client chatting
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.