This is a migrated thread and some comments may be shown as answers.

Menu Item Parent Child Relationship not working

9 Answers 193 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Amit
Top achievements
Rank 1
Amit asked on 08 Dec 2010, 02:56 PM
Hi,

I'm using Telerik RadControls Q1 2008. I have a Rad Menu on the masterpage of my application and i'm trying to bind it to a linq datacontext.

The binding works fine but my problem is That Child Items are always displayed as root items.

I have checked that ParentId of all roots items is NULL and of all the child items is that of the assigned parent. 

Below is the code :

Private Sub LoadMenuItems()
 
      Dim MenuDC As New MenuItemDataContext
 
      RadMenu1.DataSource = MenuDC.usp_TABLE_MENU_ITEM_Select().ToList()
      RadMenu1.DataBind()
   End Sub
<telerik:RadMenu ID="RadMenu1" runat="server" Skin="Office2007" DataFieldID="MENU_ITEM_ID"
                 DataFieldParentID="PARENT_ID" DataNavigateUrlField="PAGE_URL" DataTextField="MENU_ITEM_NAME"
                  DataValueField="MENU_ITEM_ID">
                <DefaultGroupSettings ExpandDirection="Down" />
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                 
                </telerik:RadMenu>

I do not know what i'm missing here.

9 Answers, 1 is accepted

Sort by
0
Amit
Top achievements
Rank 1
answered on 09 Dec 2010, 07:17 AM
Still no answer from telerik.

i haven't gotten anywhere with the issue. i'm its something trivial, but i just don't know what it is.. 

From reading other posts in this forum i know people have had issues with Root Items .. but i couldn't find any issues similar to mine.
I guess i have no choice but to wait for telerik to answer. 
Any help would be appreciated. 

Thanks 

Amit
0
Amit
Top achievements
Rank 1
answered on 12 Dec 2010, 12:23 PM
Ok its been 3 days and i have no asnwer from anyone.
In the meanwhile I've tried to dynamically build the rad menu from the result list of Linq DataContext, which also did not work.
An Interesting thing that i did found was RadMenuItem does not have a property to Set its parent ID.
(E.g. radMenuItem.parentID = 2)
If anyone from telerik reads this post. It will be good to have a property for the same.

Thanks

Amit

Note: I'm gonna revert back to using asp.net Menu and see if that works.

 
0
Yana
Telerik team
answered on 13 Dec 2010, 09:40 AM
Hi Amit,

The provided information is not enough for us, we need more details in order to help you. Can you please send us the result list so we can test it? Thanks

Greetings,
Yana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Amit
Top achievements
Rank 1
answered on 13 Dec 2010, 11:33 AM
Hi Yana,

Thanks for your reply,

Below is the sql table that i've used for Menu
MENU_ITEM_ID PARENT_ID PAGE_URL MENU_ITEM_NAME
3 NULL /MenuItemE.aspx DashBoard
4 NULL /ItemDetails.aspx Inventory
5 4 /ItemDetails.aspx Item Details




All I've done is created a simple DBML file using Linq to SQL classes and called in the Select SP (As shown in my first post).
The problem that i'm facing is that all the Menu Items Are bounded as root items and not in the hierarchical manner as they should.
Please let me know if you want any more info .. or should i submit a support ticket. 
0
Amit
Top achievements
Rank 1
answered on 13 Dec 2010, 01:56 PM
Alright,
I have refined my code and finally got it to work (YAY!) to build the Menu dynamically. Below is the Approach I used. 

Private Sub LoadMenuItems()
 
        Dim MenuDC As New MenuItemDataContext
 
        Dim itemL As New List(Of usp_TABLE_MENU_ITEM_SelectResult)
        Dim childL As New List(Of usp_TABLE_MENU_ITEM_SelectResult)
 
        For Each item As usp_TABLE_MENU_ITEM_SelectResult In MenuDC.usp_TABLE_MENU_ITEM_Select
            If item.PARENT_ID IsNot Nothing And item.PARENT_ID <> 0 Then
                childL.Add(item)
            Else
                itemL.Add(item)
            End If
        Next
 
        For i As Integer = 0 To itemL.Count - 1
            Dim rootM As New RadMenuItem
            rootM.Value = CType(itemL(i).MENU_ITEM_ID, String)
            rootM.NavigateUrl = itemL(i).PAGE_URL
            rootM.Text = itemL(i).MENU_ITEM_NAME
            For j As Integer = 0 To childL.Count - 1
                If childL(j).PARENT_ID = itemL(i).MENU_ITEM_ID Then
                    Dim childM As New RadMenuItem
                    childM.Value = CType(childL(j).MENU_ITEM_ID, String)
                    childM.NavigateUrl = childL(j).PAGE_URL
                    childM.Text = childL(j).MENU_ITEM_NAME
                    rootM.Items.Add(childM)
                End If
            Next
            RadMenu1.Items.Add(rootM)
        Next
        'RadMenu1.DataFieldID = "MENU_ITEM_ID"
        'RadMenu1.DataFieldParentID = "PARENT_ID"
        'RadMenu1.DataNavigateUrlField = "PAGE_URL"
        'RadMenu1.DataTextField = "MENU_ITEM_NAME"
        'RadMenu1.DataSource = MenuDC.usp_TABLE_MENU_ITEM_Select().ToList()
        'RadMenu1.DataBind()
    End Sub

But I would still like to know why direct binding to datasource (the commented out code) did not work properly.
Also, as i suggested in my earlier post, a property to set the parentId of a radMenuItem will be greatly appreciated.

Amit
0
Yana
Telerik team
answered on 16 Dec 2010, 11:37 AM
Hello Amit,

I created a simple page to test the provided data and the menu works as expected. Please download the attachment and give it a try.

Regarding the ParentID property - thank you for sending your suggestion, I've logged it and it will be considered.

All the best,
Yana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Amit
Top achievements
Rank 1
answered on 19 Dec 2010, 08:05 AM
Hi Yana, 

Thanks for your response, the page you provided worked fine but when i changed the data source from table to LinqDatacontext, the same issue happened once again, i dont know if this a data issue or something else. I cannot spend more time trying to solve this issue. so for now i'm gonna stick to my approach of binding the menu items dynamically (as shown in my previous post).

Thanks once again.

Amit

0
H.
Top achievements
Rank 1
answered on 07 Mar 2011, 06:25 PM
I have the same problem I use XMLDataSource in my RadMenu. I have the following xml and xsl. My problem is the all Parent and child is in the top level and I expect to have Parents in the top and Children inside each parent.

I need help!!
Thanks
HANK

XML files
<?xml version="1.0" encoding="utf-8"?>
<Orders>
  <Order>
    <Id>4c5189d7-2d39-41dc-a0cb-e5136a908543</Id>
    <Title>sssssss</Title>
    <Description>This is the e-Briefing Book.</Description>
    <Url></Url>
    <Position>1</Position>
    <ParentId></ParentId>
  </Order>
  <Order>
    <Id>39f25e84-74b4-47f9-b348-3b8beabc7a35</Id>
    <Title>sssssdddd</Title>
    <Description></Description>
    <Url></Url>
    <Position>1</Position>
    <ParentId>4c5189d7-2d39-41dc-a0cb-e5136a908543</ParentId>
  </Order>
</Orders>


XSL

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 <xsl:template match="Orders">
  <Orders>
   <xsl:apply-templates />
  </Orders>
 </xsl:template>

 <xsl:template match="Order">
  <Order  SiteId="{Id}" 
    Title="{Title}"
    Description="{Description}"
      Url="{Url}"
    Position="{Position}"
    ParentId="{ParentId}" />
 </xsl:template>

 

</xsl:stylesheet>


XMLDATASOURCE definition

<

 

asp:XmlDataSource ID="XDS"

 

 

 

DataFile="Orders.xml"

 

 

 

TransformFile="Orders.xsl"

 

 

XPath="Orders/Order"

 

 

 

runat="server"></asp:XmlDataSource>

 



RadMenu Definition

 

<telerik:RadMenu runat="server" ID="rmnuGlobalNav"

 

 

 

Skin="NIAMS" EnableEmbeddedSkins="false">

 

 

<DefaultGroupSettings RepeatColumns="1" RepeatDirection="Vertical" />

 

 

</telerik:RadMenu>

 



Behind Code

rmnuGlobalNav.DataFieldID =

"Id";

 

 

rmnuGlobalNav.DataFieldParentID =

"ParentId";

 

 

rmnuGlobalNav.DataTextField =

"Title";

 

 

rmnuGlobalNav.DataNavigateUrlField =

"Url";

 

 

rmnuGlobalNav.DataSourceID =

"XDS";

 

 

rmnuGlobalNav.DataBind();



0
Yana
Telerik team
answered on 09 Mar 2011, 10:07 AM
Hi Hank,

When using XmlDataSource the items hierarchy is built in the xml file, not using DataFieldID, DataFieldParentID properties. Please check this help article for more details.

Kind regards,
Yana
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Menu
Asked by
Amit
Top achievements
Rank 1
Answers by
Amit
Top achievements
Rank 1
Yana
Telerik team
H.
Top achievements
Rank 1
Share this question
or