How to invoke SubCategories in dropdown on the basis of Category selected in first dropdown

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
Hi,

Requirement is I have 2 dropdowns on my page.
First one displays Categories fetched from database
e.g. Category dropdowns displays data like this:
Id     Value
1      Cat1
2      Cat2

Cat1 have subcategories like SubCat11 & SubCat12
& Cat2 have subcategories like SubCat21 & SubCat22

My requirement is when I select Cat1, SubCategory dropdown should only display SubCat11 & SubCat12
& when I select Cat2, SubCategory dropdown should only fetch SubCat21 & SubCat22

I am new to NopCommerce & Dot Net.
I am able to display Categories from database on cshtml page, able to get changed CatId, send it to service & get Subcats for selected Category. But after trying for 4-5 hrs also not getting how to display this Subcat data in dropdown.
Kindly help. Thanks in advance.
11 years ago
read these and see if they help

https://www.nopcommerce.com/boards/t/11858/sub-cat-is-display-when-page-is-load.aspx

https://www.nopcommerce.com/boards/t/11949/how-to-generate-neat-multi-level-category-menu.aspx
11 years ago
Thanks for your reply. I went thru the links given but problem is not solved. Can you please explain a bit.

I have created 1 new method in Controller which takes 2 params. Depending upon param it will return Cat List or SubCat List.But not able to call this method from Action. Its giving error.
Please help. Thanks.
11 years ago
I don't know what you're expecting when / (or) if you even have more than 2 levels (cat / sub cat / sub-sub cat / etc.)...
But, I would think that if you're working with (or replacing) Views\Catalog\CategoryNavigation.cshtml, that you could just loop through the model IList<CategoryNavigationModel>, and based on category.NumberOfParentCategories, populate your dropdowns.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.