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

Determining Right Mouse Click for RowSelecting?

3 Answers 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lenny_shp
Top achievements
Rank 2
Lenny_shp asked on 02 Feb 2010, 03:32 PM
2009.3.1210.35
My OnRowSelecting launches the URL contained in the row.   If I link contextual menu to it, it would execute RowSelecting then pop up the menu.  

Is there a way to determine that the Contextual Menu will be fired (or right click) in the OnRowSelecting event code so I can prevent the launch of the URL?

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 05 Feb 2010, 01:55 PM
Hello Lenny,

Please download the attached demo and let me know whether it works properly on your end.

Best regards,
Daniel
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Lenny_shp
Top achievements
Rank 2
answered on 29 Mar 2010, 04:55 PM
I still get the URL opened.

            <ClientSettings Selecting-AllowRowSelect="true" AllowColumnsReorder="false" AllowDragToGroup="false" ReorderColumnsOnClient="false" EnableRowHoverStyle="true">
                <ClientEvents OnFilterMenuShowing="filterMenuShowing"  OnRowSelecting="RowSelecting" OnRowContextMenu="RowContextMenu"/>
                <Scrolling AllowScroll="False" UseStaticHeaders="True" />
            </ClientSettings>




    
<telerik:RadScriptBlock  runat="server"
            <script language="javascript" type="text/javascript"
 
                function RowSelecting(sender, eventArgs) { 
                    var parentRow = eventArgs.get_tableView().get_parentRow();  //Suppress child table rowclick 
                    if (parentRow != null) { 
                        eventArgs.set_cancel(true); 
                    } 
                    else { 
                        RowClick(sender, eventArgs); 
                    }                      
                } 
 
                function RowClick(sender, eventArgs) { 
                     
                    var grid = $find("<%= RadGrid1.ClientID %>"); 
                    var rowControl = grid.get_masterTableView().get_dataItems()[eventArgs.get_itemIndexHierarchical()];                     
                    var sURL = rowControl.getDataKeyValue("Data"); 
          setTimeout(function(){window.open(sURL);},0); //Allows row highlight to process first then window.open                       
  
                    } 
                } 
 
                function RowContextMenu(sender, eventArgs) { 
                    var menu = $find("<%=RadGridMenu1.ClientID %>"); 
                    var evt = eventArgs.get_domEvent(); 
 
                    evt.cancelBubble = true
                    evt.returnValue = false
 
                    if (evt.stopPropagation) { 
                        evt.stopPropagation(); 
                        evt.preventDefault(); 
                    }                     
 
                    if (evt.target.tagName == "INPUT" || evt.target.tagName == "A") { 
                        return; 
                    } 
 
                    var index = eventArgs.get_itemIndexHierarchical(); 
                    document.getElementById("radGridClickedRowIndex").value = index
 
                    sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(), true); 
 
                    menu.show(evt); 
                }                 
 
            </script> 
        </telerik:RadScriptBlock >
0
Lenny_shp
Top achievements
Rank 2
answered on 29 Mar 2010, 05:11 PM
2009.3.1210.35

If I force this in RowContextMenu, what happens at RowSelecting (or RowSelected) is that right click will not detect it's stopped, but left click detect it's stopped.  (opposite of what I am looking for)

                    evt.stopPropagation();
                    evt.preventDefault(); 

---------------
Update:  If I change to RowClicked then it worked as expected.
 
Tags
Grid
Asked by
Lenny_shp
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Lenny_shp
Top achievements
Rank 2
Share this question
or