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

Rad Menu as a Context Menu

2 Answers 90 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Hemant
Top achievements
Rank 1
Hemant asked on 10 Oct 2008, 10:20 AM

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 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 10 Oct 2008, 11:52 AM

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.

0
Hemant
Top achievements
Rank 1
answered on 10 Oct 2008, 12:30 PM
i got Sample But when i tried it with master page it is not working :(
Tags
Menu
Asked by
Hemant
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Hemant
Top achievements
Rank 1
Share this question
or