Rad Menu as a Context Menu

3 posts, 0 answers
  1. Hemant
    Hemant avatar
    3 posts
    Member since:
    Sep 2007

    Posted 10 Oct 2008 Link to this post

    Hi ,

      I am trying to use the Rad Menu for shwoing as a Context Menu.

     

    I am using

    1 ) RadMenu.Net2

    2 ) Telerik.WebControls

     

    Now I have solution it for using Telerik.Web.UI,but now it is not possible me to change it (to newer) so I want to continue with Telerik.WebControls.

     

    My Reuirement is,

      I have to show the Context Menu on Rad Grid Columns Header to show and hide the columns

     

    If possible please send me Sample Code with Telerik.WebControls &  RadMenu.Net2

     

     

     

    <script type="text/javascript">

                     var activeTable;

                     var colIndex;

                    

                     function ColumnContextMenu(sender, eventArgs)

                     {

                        activeTable = sender.get_masterTableView();

                        colIndex = GetRealCellIndex(sender.get_masterTableView(), eventArgs.get_gridColumn().get_element());

                        

                     }

                     function GetRealCellIndex(tableView, cell)

                     {

                         for(var i = 0; i < tableView.get_columns().length; i++)

                         {

                             if(tableView.get_columns()[i].get_element()== cell)

                             {

                                 return i;

                             }

                         }

                     }

                     function ClientItemClicked(sender, eventArgs)

                     {

                        switch(eventArgs.get_item().get_text())

                        {

                            case "CustomerID":

                               activeTable.showColumn(0);

                              break;  

                            case "CompanyName":

                              activeTable.showColumn(1);

                              break;

                            case "ContactName":

                               activeTable.showColumn(2);

                              break;  

                            case "ContactTitle":

                              activeTable.showColumn(3);

                              break;   

                            case "Address":

                              activeTable.showColumn(4);

                              break;

                            case "PostalCode":

                              activeTable.showColumn(5);

                              break

                            case "Hide column":

                              activeTable.hideColumn(colIndex);

                              break;  

                            default:

                             break;

                        } 

                        

                     }

                     function RestoreColumns()

                     {

                        var grid = $find("<%=rdCompanyList.ClientID %>");

                       

                        for(i = 0; i < grid.get_masterTableView().get_columns().length; i++)

                        {

                          grid.get_masterTableView().showColumn(i);

                        }

                     }

                    </script>

     

     

     

     

    <radM:RadMenu ID="RadMenu1" IsContext="True" runat="server" Skin="Outlook" ContextMenuElementID="rdCompanyList" OnClientClick="ClientItemClicked">

             <RootGroupPersistable>

                <radM:MenuItem ID="MenuItem1" runat="server" Text="Show Columns" Value="TIN">

                <ChildGroupPersistable>

                    <radM:MenuItem ID="itemTIN" runat="server" Text="TIN" Value="TIN">

                    </radM:MenuItem>

                    <radM:MenuItem ID="itemDefaultCountry" runat="server" Text="Default Country" Value="DefaultCountry">

                    </radM:MenuItem>

                    <radM:MenuItem ID="itemRoundingLevel" runat="server" Text="Rounding Level" Value="RoundingLevel">

                    </radM:MenuItem>

                    <radM:MenuItem ID="itemSSTPID" runat="server" Text="SSTP ID" Value="SSTPID">

                    </radM:MenuItem>

                    <radM:MenuItem ID="itemSSTEDate" runat="server" Text="SST Effective Date" Value="SSTEDate">

                    </radM:MenuItem>

                </ChildGroupPersistable>

                </radM:MenuItem>

            </RootGroupPersistable>

          </radM:RadMenu>

     

     

    <radG:RadGrid  ID="rdCompanyList" runat="server">

    <ClientSettings AllowColumnHide="true">

               <ClientEvents OnColumnContextMenu="ColumnContextMenu" />

    </ClientSettings

    >

     

     

    </telerik

    :

    RadGrid

    >

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 10 Oct 2008 Link to this post

    Hello Hemant,

    You can refer to the following code library submission link which demonstrates how to show/hide grid columns client-side by means of context menu, on clicking a column header and find out whats missing at your end.
    Show/hide grid columns with RadMenu as context menu

    Thanks
    Shinu.

  3. Hemant
    Hemant avatar
    3 posts
    Member since:
    Sep 2007

    Posted 10 Oct 2008 Link to this post

    i got Sample But when i tried it with master page it is not working :(
Back to Top