Hi I have a RadMenu that I am populating dynamically through the code behind. I need to add checkboxes to each child item that allows the user to make a selection or multiple selections in the menu. Is it possible to do this? Someone had suggested to me that I try and nest a RadComboBox inside of the RadMenu, but I'm having no luck with that. I will paste my code below if it will help.
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<telerik:RadMenu ID="handsetMenu" runat="server">
<Items>
</Items>
</telerik:RadMenu>
</ContentTemplate>
</asp:UpdatePanel>
Code Behind:
protected void createFilter(int categoryid)
{
List<int> productIds = new List<int>();
DataRow[] productRow = CategoriesProductsData.Tables["Products"].Select("Category_ID = " + 573);
productIds = productRow.Select(p => int.Parse(p["Product_ID"].ToString())).ToList();
ITCProductService pService = new TCProductServiceClient();
var productTuples = (pService.GetProductsAttributes(productIds));
List<Tuple<int, CustomAttribute>> customAttributes = new List<Tuple<int, CustomAttribute>>();
foreach (var productTuple in productTuples)
{
foreach (var attributeTuple in productTuple.m_Item2)
{
var customAttribute = new Tuple<int, CustomAttribute>(productTuple.m_Item1, new CustomAttribute(attributeTuple));
customAttributes.Add(customAttribute);
}
}
List<CustomAttributeCategory> categories = new List<CustomAttributeCategory>();
var categoryList = customAttributes.Select(a => a.Item2).Select(a => a.Attribute.Category).GroupBy(a => a.AttributeCategoryId);
var CatProdList = new List<CustomAttributeCategory>();
foreach (var category in categoryList)
{
var CatProd = new CustomAttributeCategory();
var prodIDList = from product in customAttributes
where product.Item2.Attribute.CategoryId == category.Key
select Tuple.Create(product.Item1, product.Item2);
CatProd.Category = customAttributes.Select(a => a.Item2.Attribute.Category).Where(a => a.AttributeCategoryId == category.Key).FirstOrDefault();
CatProd.ProdAttributesTuple = new List<Tuple<int, CustomAttribute>>();
CatProd.ProdAttributesTuple = prodIDList.ToList();
CatProdList.Add(CatProd);
}
foreach (var cat in CatProdList)
{
var itemCategory = new RadMenuItem(cat.Category.Name);
handsetMenu.Items.Add(itemCategory);
var option = cat.ProdAttributesTuple.GroupBy(a => a.Item2.Attribute.Value).ToList();
foreach (var attr in option)
{
itemCategory.Items.Add(new RadMenuItem(attr.Key));
}
}
}
protected void handsetMenu_ItemDataBound(object sender, RadMenuEventArgs e)
{
DataRowView row = (DataRowView)e.Item.DataItem;
}
public class CustomAttributeCategory
{
public AttributeCategoryModel Category { get; set; }
public List<Tuple<int, CustomAttribute>> ProdAttributesTuple { get; set; }
}
public class CustomAttribute
{
public AttributeModel Attribute { get; set; }
public List<int> ProductIds { get; set; }
public CustomAttribute(AttributeModel attribute)
{
Attribute = attribute;
ProductIds = new List<int>();
}
}