Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
495
Populating Webmenu from XML file
posted

 I have been trying to populate the Webmenu with items from an XML file.  Everything works great except for the fact that I can only seem to get one main item (parent) on the menu.  If I try to add more an error informing me that only one root is allowed pops up.  Does anyone have a sample XML file that successfully populates a Webmenu?

 

Thanks 

  • 903
    posted

     (I have posted this in another thread too.  It is relevant here too so I hope no-one objects.  I found the link unhelpful)

    Have a look at this example below.  I did not find the documentation very helpful and got to this by trial and error.  There are a few tricks to get this working.

    1.  To get rid of the "root" men (and possible an "Item" Menu) you must add "/root/Item" as the Xpath expression when you Configure Data Source

    2.  Do not enclose your sub Items within <Items></Items> tags as you will just get a submenu called Items.  Likewise do not create <Images> tags as they are not necessary.  The markup when you preset a menu has these tags and so, in the absence of any samples (Infragistics please note) you may be fooled into thinking these are required.

    3. Bind the Item tag once and set the Depth to -1.  The documentation example (and I only found anything useful in the NET 8.3 docs) has 2 levels of Menu and sets the Depth to 2.  This is confusing as the result is that the you get 2 levels of menu with the text "Item" in them.  The example has a top menu with just the word "Item" - I think duh! is appropriate here.  Why -1  I don't know. And no you can't change /root/Item in the Xpath to /root and then set Depth to 0.

    4. In the Item Binding set ImageUrlField to "ImageUrl", TargetUrlField to "TargetUrl" and TextField to "Text".  I am not sure whether these could ever be set to anything else meaningful.  Anyway these are what did it in my example below

    The example works fine as a Horizontal menu.  I have tested this in a simple example but not yet implemented it in the full application where I have made menu changes using code, as 4 months ago I could not figure the XML at all.

    <root>
            <Item ImageUrl="./images/home.gif" TargetUrl="HomePage.aspx"
                Text="Home Page">
            </Item>
            <Item ImageUrl="./images/icon-calendar.gif" Separator="True" Text="">

            </Item>
            <Item ImageUrl="./images/BlockBook.gif" TargetUrl="DiaryDisplay.aspx"
                Text="Zone Manager Diary">
            </Item>
            <Item ImageUrl="./images/FlatBed_ArriveOrig.gif" Text="Diary Entries">

                    <Item ImageUrl="./images/FlatBed_ArriveOrig.gif"
                        TargetUrl="EnterBooking.aspx" Text="Enter a Booking">
                    </Item>
                    <Item ImageUrl="./images/WebViewandEdit.gif" TargetUrl="Bookings.aspx"
                        Text="View and Edit Bookings">
                    </Item>
            </Item>
            <Item ImageUrl="./images/bars.gif" Separator="True" Text="">
            </Item>
            <Item Hidden="True" ImageUrl="./images/FlatBed_ArriveQuestion.gif"
                Text="Booking Requests">

                    <Item TargetUrl="BookRequest.aspx" Text="Enter a Booking Request">
                    </Item>
                    <Item TargetUrl="OutstandingBookings.aspx"
                        Text="View and Edit Booking Requests">
                    </Item>
            </Item>
            <Item ImageUrl="./images/GATEOPEN.gif" Text="Gate Operations">

                    <Item TargetUrl="GateOpsArrive.aspx" Text="Arrive Vehicles"
                        ToolTip="Log vehicles on site">
                    </Item>
                    <Item TargetUrl="GateOpsDepart.aspx" Text="Depart Vehicles"
                        ToolTip="Log Vehicles off Site">
                    </Item>

            </Item>
            <Item ImageUrl="./images/help.gif" TargetUrl="Help.aspx" Text="Help">
            </Item>
            <Item TargetUrl="ZM_Logout.aspx" Text="Log Off">
            </Item>

    </root>
  • 28464
    posted

    I believe there is one forum thread in our community forums which shows a scenario very similar to what you need to achieve - bind the menu to an xml datasource and have multiple root items - please, follow the link below

    http://forums.infragistics.com/forums/p/2781/16371.aspx#16371

    for additional details about the desired Xml structure. You can also use the ItemBinding server-side event to customize 

    Hope this helps.