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

[Solved] Adding separator between menu item in sitemap

6 Answers 262 Views
Menu
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tawit
Top achievements
Rank 1
Tawit asked on 22 Dec 2011, 08:45 AM
I use sitemap binding for generate menu item.
How can adding seperator to "----------------------"

<siteMapNode>
    <siteMapNode title="Billing">
      <siteMapNode area="Billing" controller="CustomerDiscount" action="Index" title="Customer Discount" />
      <siteMapNode title="Customer Discount" visible="false">
        <siteMapNode area="Billing" controller="CustomerDiscount" action="Edit" title="Edit Customer Discount" />
        <siteMapNode area="Billing" controller="CustomerDiscount" action="Create" title="Create Customer Discount" />
      </siteMapNode>

      <siteMapNode area="Billing" controller="-" action="Index" title="----------------------" />
     
      <siteMapNode area="Billing" controller="BillingCalculation" action="Index" title="Billing Calculation" />
      <siteMapNode title="Billing Calculation" visible="false">
        <siteMapNode area="Billing" controller="BillingCalculation" action="Edit" title="Edit Billing Calculation" />
        <siteMapNode area="Billing" controller="BillingCalculation" action="Create" title="Create Billing Calculation" />
      </siteMapNode>

      <siteMapNode area="Billing" controller="BillingResult" action="Index" title="Billing Result" />
      <siteMapNode title="Billing Result" visible="false">
        <siteMapNode area="Billing" controller="BillingResult" action="Edit" title="Edit Billing Result" />
        <siteMapNode area="Billing" controller="BillingResult" action="Create" title="Create Billing Result" />
      </siteMapNode>
    </siteMapNode>   
</siteMapNode>

6 Answers, 1 is accepted

Sort by
0
John DeVight
Top achievements
Rank 1
answered on 16 Jan 2012, 05:51 PM
Hi Tawit,

As far as I know, there is no support for a separator line.  However, what I have done in this situation is add the separator line after the menu is rendered.  Assuming the name of your menu controls is "Menu", you could add the following code to the Html.Telerik().ScriptRegistrar.OnDocumentReady() method:

$('#Menu').children('li.t-item:contains("Billing")')
    .find('span.t-link:contains("Customer Discount")')
        .closest('li.t-item')
        .after($('<li/>').attr('class','t-item t-state-default').html('<hr/>'))

What this does is locate the "Billing" menu, find the "Customer Discount" menu item and add a "separator line" after the "Customer Discount" menu item.

Hope this helps.

Let me know if you would like for me to post a sample application...

Regards,

John DeVight
0
Tawit
Top achievements
Rank 1
answered on 17 Jan 2012, 09:20 AM
Hi John,

    I used your sample code in my project. But it nothing happend.
    Please post a sample application for me.

Thank  you,
Tawit.
0
John DeVight
Top achievements
Rank 1
answered on 17 Jan 2012, 01:56 PM
Hi Tawit,

Sorry about that.  I based my code on a menu where the menu item wasn't a link to another page.  The following should work:

$('#Menu').children('li.t-item:contains("Billing")'
    .find('.t-link:contains("Customer Discount")'
        .closest('li.t-item'
        .after($('<li/>').attr('class','t-item t-state-default').html('<hr/>'))

I'll post a sample application shortly...

Regards,

John DeVight
0
John DeVight
Top achievements
Rank 1
answered on 17 Jan 2012, 02:05 PM
Attached is a sample application.
0
Tawit
Top achievements
Rank 1
answered on 20 Jan 2012, 04:22 AM
Thank you very much.
0
Deepak
Top achievements
Rank 1
answered on 05 Dec 2012, 10:55 PM
Here's another solution:

In the SiteMap, add the following:
<siteMapNode title="---" /> 

Add the Client-side OnLoad event to the menu and put the following code in there:
$("#TopMenu span:contains(---)").each(function ()         
{             
$(this).html("<hr/>");             
$(this).css("padding-left""0px");             
$(this).css("padding-right""0px");         
});
Tags
Menu
Asked by
Tawit
Top achievements
Rank 1
Answers by
John DeVight
Top achievements
Rank 1
Tawit
Top achievements
Rank 1
Deepak
Top achievements
Rank 1
Share this question
or