I have the RadGrid with drag and drop function and context menu. When I select multiple rows and right click, the context menu shown and the "no access" cursor is also appear (change of "no access" cursor is in ongriddragstarted event).
How do I stop triggering the OnRowDragStarted when right click on the selected multiple rows? Thanks!!
aspx:
How do I stop triggering the OnRowDragStarted when right click on the selected multiple rows? Thanks!!
aspx:
<%@ Page Language="C#" AutoEventWireup="true" Codebehind="Default.aspx.cs" Inherits="Default" %>
<
html
>
<
head
runat
=
"server"
>
<
title
></
title
>
<
style
type
=
"text/css"
>
.noAccessCursor, .noAccessCursor *
{
cursor:url('noaccess.cur'), default !important;
}
</
style
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
asp:ScriptManager
ID
=
"ScriptManager"
runat
=
"server"
/>
<
telerik:RadScriptBlock
runat
=
"server"
ID
=
"ScriptBlock"
>
<
script
type
=
"text/javascript"
>
function gridRowContextMenu(sender, args)
{
// remove the cursor cause but the onrowdragstarted
Sys.UI.DomElement.removeCssClass(document.documentElement, "noAccessCursor");
var evt = args.get_domEvent();
if(evt.target.tagName == "INPUT" || evt.target.tagName == "A")
return;
var menu = $find("<%= ContextMenu1.ClientID %>");
menu.show(evt);
//evt.cancelBubble = true;
//evt.returnValue = false;
//if (evt.stopPropagation)
//{
// evt.stopPropagation();
// evt.preventDefault();
//}
}
var destTaxonomyID;
//var expandedNodes = [];
function gridRowDropping(sender, args)
{
args.set_cancel(true);
alert("Dropped");
// reset the cursor to default
Sys.UI.DomElement.removeCssClass(document.documentElement, "noAccessCursor");
}
function gridRowDragStarted(sender, args)
{
Sys.UI.DomElement.addCssClass(document.documentElement, "noAccessCursor");
}
</
script
>
</
telerik:RadScriptBlock
>
<
telerik:RadContextMenu
ID
=
"ContextMenu1"
runat
=
"server"
Skin
=
"Vista"
>
<
Items
>
<
telerik:RadMenuItem
Text
=
"Menu 1"
/>
<
telerik:RadMenuItem
Text
=
"Menu 2"
/>
</
Items
>
<
Targets
>
<
telerik:ContextMenuControlTarget
ControlID
=
"GridDocument"
/>
</
Targets
>
</
telerik:RadContextMenu
>
<
telerik:RadGrid
ID
=
"Grid1"
runat
=
"server"
AutoGenerateColumns
=
"False"
Skin
=
"Vista"
AllowPaging
=
"True"
AllowSorting
=
"True"
AllowMultiRowSelection
=
"true"
GridLines
=
"None"
Width
=
"100%"
Height
=
"345px"
BorderWidth
=
"0px"
OnRowDrop
=
"Grid1_RowDrop"
>
<
PagerStyle
AlwaysVisible
=
"true"
Mode
=
"NextPrevAndNumeric"
/>
<
MasterTableView
DataKeyNames
=
"ID"
ClientDataKeyNames
=
"ID"
TableLayout
=
"Fixed"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Title"
HeaderText
=
"Title"
UniqueName
=
"Title"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
EnableRowHoverStyle
=
"True"
AllowRowsDragDrop
=
"true"
>
<
Selecting
AllowRowSelect
=
"True"
></
Selecting
>
<
ClientEvents
OnRowContextMenu
=
"gridRowContextMenu"
OnRowDropping
=
"gridRowDropping"
OnRowDragStarted
=
"gridRowDragStarted"
/>
<
Scrolling
AllowScroll
=
"true"
UseStaticHeaders
=
"true"
/>
<
Resizing
AllowColumnResize
=
"True"
EnableRealTimeResize
=
"true"
ClipCellContentOnResize
=
"true"
>
</
Resizing
>
</
ClientSettings
>
</
telerik:RadGrid
>
</
form
>
</
body
>
</
html
>
using
System;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Data;
using
System.Configuration;
using
System.Web.Security;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
using
Telerik.Web.UI;
public
partial
class
Default : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
DataTable tb =
new
DataTable();
tb.Columns.Add(
"ID"
);
tb.Columns.Add(
"Title"
);
for
(
int
i = 0; i < 10; i++)
{
DataRow row = tb.NewRow();
row[
"ID"
] = i;
row[
"Title"
] =
"Title "
+ i;
tb.Rows.Add(row);
}
Grid1.DataSource = tb;
Grid1.DataBind();
}
}
protected
void
Grid1_RowDrop(
object
sender, GridDragDropEventArgs e)
{
}
}