Context Menu

6 posts, 0 answers
  1. Kousalya
    Kousalya avatar
    15 posts
    Member since:
    Mar 2008

    Posted 29 May 2008 Link to this post

    I want a tick mark to be shown beside the selected item of the context menu.
     
  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 29 May 2008 Link to this post

    Hi Kousalya,

    Here is one possible solution:

      <script type="text/javascript">  
        function SetImage(sender, eventArgs)  
        {  
            var menu = sender;  
            //clear image for previously selected item  
             for (var i=0; i< menu.get_allItems().length; i++)  
             {          
               menu.get_allItems()[i].set_imageUrl("spacer.gif");             
             }  
             eventArgs.get_item().set_imageUrl("check.gif");  
        }      
        </script> 
        <telerik:RadContextMenu ID="RadContextMenu1" OnClientItemClicking="SetImage" runat="server"

    I have attached the transparent spacer.gif image too.




    Greetings,
    Peter
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Kousalya
    Kousalya avatar
    15 posts
    Member since:
    Mar 2008

    Posted 30 May 2008 Link to this post

    I have written the code like this
    function SetImage(sender, eventArgs)  
        {  
            var menu = sender;  
            //clear image for previously selected item  
             for (var i=0; i< menu.length; i++)  
             {          
               menu.Items[i].imageUrl("spacer.gif");             
             }  
             eventArgs.item.imageUrl("check.gif");  
        }      
    becoz if i put menu.get_allItems()  it is sayiing there is no such function.
    I am not able to set the image to the item selected.
  4. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 30 May 2008 Link to this post

    Hi Kousalya,

    You are probably not using RadMenu for ASP.NET Ajax. Please post in the correct forum so we can provide the best solution for your case.

    This online example demonstrates how to display a check mark for the clicked item:

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Kousalya
    Kousalya avatar
    15 posts
    Member since:
    Mar 2008

    Posted 30 May 2008 Link to this post

    Hi,

     I am using radmenu,
      Code :

    <radM:RadMenu ID="rmTree" IsContext="True" CausesValidation="true" runat="server"

    Skin="Outlook" ContextMenuElementID="none" OnClientItemClicking="OnClick" OnItemClick="rmTree_ItemClick" >

    <Items>
    <radM:RadMenuItem Text="Add">
    <Items>
    <radM:RadMenuItem Text="Hierarchy" ImageUrl="~\Images\ic_hirarchy.gif" />

    <radM:RadMenuItem Text="Country" ImageUrl="~\Images\ic_com_country.gif" />

    <radM:RadMenuItem Text="State" ImageUrl="~\Images\ic_com_state.gif" />

    <radM:RadMenuItem Text="Building" ImageUrl="~\Images\ic_com_building.gif" />

    <radM:RadMenuItem Text="Structure" ImageUrl="~\Images\ic_structure.gif">

    </radM:RadMenuItem>

    <radM:RadMenuItem Text="Land" ImageUrl="~\Images\ic_land.gif">

    </radM:RadMenuItem>

    <radM:RadMenuItem Text="Project" ImageUrl="~\Images\ic_project.gif">

    </radM:RadMenuItem>

    </Items>

    </radM:RadMenuItem>

    <radM:RadMenuItem Text="Rename" />

    <radM:RadMenuItem Text="Activate" />

    <radM:RadMenuItem Text="De-Activate" />

    <radM:RadMenuItem Text="TransactionType" >

    <Items>

    <radM:RadMenuItem Text="JobPlan" >

    </radM:RadMenuItem>

    <radM:RadMenuItem Text="Survey">

    </radM:RadMenuItem>

    <radM:RadMenuItem Text="All">

    </radM:RadMenuItem>

    </Items>

    </radM:RadMenuItem>

    </Items>

    </radM:RadMenu>

    and the javascript fundtion

    function

    OnClick(sender, eventArgs)

    {

    var menu = sender;

     

    //clear image for previously selected item

     for (var i=0; i< menu.Items.length; i++)

    {

     menu.Items[i].Image= "/Images/spacer.gif";

     }

    eventArgs.Items[0].ImageUrl=

    "/Images/tick.gif";

     

     

    }
    I want to set the tick mark functionality only to the subitems of
    transaction type in the rad menu

  6. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 30 May 2008 Link to this post

    Hi Kousalya,

    The example I've sent you earlier demonstrates the required approach. I think you can easily adapt it to support your specific requirements.

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top