Need dropdown listbox using categoryID, parentID, level
-
- Lieutenant, Jr. Grade (LT JG)
- Posts: 33
- Joined: Mon Mar 10, 2008 12:18 am
- Location: us
- Contact:
Need dropdown listbox using categoryID, parentID, level
Can anyone modify categorydropdownlist to include categoryID, parentID, level as query parameters so I can set up my major categories as separate lists?
Thx in advance
Thx in advance
Lab supplies, consumables & chemicals
http://www.espchemicals.com
http://www.espchemicals.com
- m_plugables
- Commander (CMDR)
- Posts: 149
- Joined: Tue Mar 11, 2008 12:44 am
- Contact:
Re: Need dropdown listbox using categoryID, parentID, level
You need to modify the ConLib/CategoryDropDownList.ascx.cs file. Locate the following line of code in the file
and replace with the following line of code
Now made the CategoryRedir() function look like
Now CategoryId, ParenId and Level all information is available in the above function for usage.
Code: Select all
subcatList.Add(new ListItem(prefix + subcat.Name, subcat.CategoryId.ToString()));
Code: Select all
subcatList.Add(new ListItem(prefix + subcat.Name, subcat.CategoryId.ToString()+","+subcat.ParentId.ToString()+","+level.ToString()));
Code: Select all
private void CategoryRedir()
{
string[] queryParameters = CategoryList.SelectedValue.Split(',');
int categoryId = AlwaysConvert.ToInt(queryParameters[0]);
int parentId = AlwaysConvert.ToInt(queryParameters[1]);
int level = AlwaysConvert.ToInt(queryParameters[2]);
if (categoryId == 0) Response.Redirect(NavigationHelper.GetHomeUrl());
Category category = CategoryDataSource.Load(categoryId);
if (category != null)
{
Response.Redirect(category.NavigateUrl);
}
}
Visit the links below to Download Plugins for your AC7 Store
http://www.plugables.com
http://blog.plugables.com
-
- Lieutenant, Jr. Grade (LT JG)
- Posts: 33
- Joined: Mon Mar 10, 2008 12:18 am
- Location: us
- Contact:
Re: Need dropdown listbox using categoryID, parentID, level
Thx very much. Appreciate you time.
Lab supplies, consumables & chemicals
http://www.espchemicals.com
http://www.espchemicals.com
-
- Lieutenant, Jr. Grade (LT JG)
- Posts: 22
- Joined: Wed Jun 24, 2009 3:39 pm
Re: Need dropdown listbox using categoryID, parentID, level
Hi, could I get some further clarification on this code?
In my situation, I have 3 major cateogories: Brands, Lighting, and Collections. I need a separate drop down list for each category.
How would I use this code to specify, for example, just "Collections"? I assume I have to plug in the CategoryID somewhere, but I can't figure out where to do it.
Any help would be greatly appreciated.
In my situation, I have 3 major cateogories: Brands, Lighting, and Collections. I need a separate drop down list for each category.
How would I use this code to specify, for example, just "Collections"? I assume I have to plug in the CategoryID somewhere, but I can't figure out where to do it.
Any help would be greatly appreciated.
Re: Need dropdown listbox using categoryID, parentID, level
Yes you can use the category Id in the control to get items only from that category. You can probably define a parameter CategoryId for the control and the place where you use it in the scriptlet you can set the category id.deadlybuda wrote:Hi, could I get some further clarification on this code?
In my situation, I have 3 major cateogories: Brands, Lighting, and Collections. I need a separate drop down list for each category.
How would I use this code to specify, for example, just "Collections"? I assume I have to plug in the CategoryID somewhere, but I can't figure out where to do it.
Any help would be greatly appreciated.
- mmackrell
- Lieutenant, Jr. Grade (LT JG)
- Posts: 50
- Joined: Sun Mar 28, 2010 7:41 pm
- Location: Zelienople, PA
- Contact:
Re: Need dropdown listbox using categoryID, parentID, level
This is a great post, but I have a question. I assume that I would set the parent category id in the scriplet. This is what I have in the scriptlet and it appears to not be working:
[[ConLib:Custom/SimpleCategoryList ]]
[[ConLib:Custom/CategoryDropDownList Levels="1" Prefix="." AutPostBack="true" CacheDuration="0" parentId="5373"]]
I have also tried changing the category id in the aspx like you referenced in viewtopic.php?f=44&t=11652 and that does not work either.
I am not a developer, so direction would be appreciated.
Oh, I would also like to know where I would go to set the width for this dropdown list. I put have played around with putting this in it's own div with a set width, but that doesn;t seem to be cutting it. Is there a setting in the aspx.cs file that would control the wrap of the list?
[[ConLib:Custom/SimpleCategoryList ]]
[[ConLib:Custom/CategoryDropDownList Levels="1" Prefix="." AutPostBack="true" CacheDuration="0" parentId="5373"]]
I have also tried changing the category id in the aspx like you referenced in viewtopic.php?f=44&t=11652 and that does not work either.
I am not a developer, so direction would be appreciated.
Oh, I would also like to know where I would go to set the width for this dropdown list. I put have played around with putting this in it's own div with a set width, but that doesn;t seem to be cutting it. Is there a setting in the aspx.cs file that would control the wrap of the list?
- mmackrell
- Lieutenant, Jr. Grade (LT JG)
- Posts: 50
- Joined: Sun Mar 28, 2010 7:41 pm
- Location: Zelienople, PA
- Contact:
Re: Need dropdown listbox using categoryID, parentID, level
I figured out where to set the width for the drop down list - yay...
Again, any help with setting the parent category id would be greatly appreciated.
Regards,
Margie
Again, any help with setting the parent category id would be greatly appreciated.
Regards,
Margie
Re: Need dropdown listbox using categoryID, parentID, level
This control doesn't support any ParentId parameter at scriptlet level. The discussion being done in few posts above makes use of custom parent id parameter passed through query string. If you want to support ParentId in this control to list child categories only that can be used via scriptlet then you need to put something like in this control.mmackrell wrote:I figured out where to set the width for the drop down list - yay...
Again, any help with setting the parent category id would be greatly appreciated.
Regards,
Margie
Code: Select all
private int _ParentId;
public int ParentId
{
get{return _ParentId;}
set{_ParentId=value;}
}
Code: Select all
categoryList = GetCategoryListItemsRecursive(0, startLevel);
Code: Select all
categoryList = GetCategoryListItemsRecursive(ParentId, startLevel);
- mmackrell
- Lieutenant, Jr. Grade (LT JG)
- Posts: 50
- Joined: Sun Mar 28, 2010 7:41 pm
- Location: Zelienople, PA
- Contact:
Re: Need dropdown listbox using categoryID, parentID, level
This works GREAT!!! Thanks for all your help Mazhar
Margie
Margie
- mmackrell
- Lieutenant, Jr. Grade (LT JG)
- Posts: 50
- Joined: Sun Mar 28, 2010 7:41 pm
- Location: Zelienople, PA
- Contact:
Re: Need dropdown listbox using categoryID, parentID, level
Mazhar,
Another quick question pertaining to this. I only want one level appearing from my parent category, so I enter
However, I am still seeing more the one level down, how do I correct this? I have tried setting the levels to 0 and I still see multiple levels down.
Thanks in advance.
Margie
Another quick question pertaining to this. I only want one level appearing from my parent category, so I enter
Code: Select all
[[ConLib:Custom/CategoryDropDownList Levels="1" AutPostBack="true" HomeText=" Hospitals by Department" CacheDuration="0" Prefix="" ParentId="5525"]]
Thanks in advance.
Margie