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

Drag n Drop grid to Grid as per Example Problem

5 Answers 223 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Neal
Top achievements
Rank 1
Neal asked on 13 May 2008, 01:53 PM
Hi,

I'm using(amended) the Grid to grid drag n drop solution for a Folder browser, "file copy" from one folder to another,
The problem I have is

when 

mouseUpHandler event in dragdro.js fires,
the  radGridOver var is empty, so no Ajax postback.
I tracked it to the mouseOverHandler(var mouseOverHandler = function(e))

and after the check for IE it seems to exit, as the debug window.alert does not fire..
I am using IE 7, and the demo project does run and swap grid rows,..code is identical(cut n pasted),

var
mouseOverHandler = function(e)

{

if (!e)

var e = window.event;

var parentEl;

if(e.srcElement) //IE{

//debug
window.alert("ParentE1 = " + parentEl.id);


The above  alert does not fire
...
...
...
 ....mouseUpHandler..
...
 this shows radGridOver =""

if

(radGridOver != "" && radGridOver != movedRow.Owner.OwnerID) {

//debug
window.alert(

"radGridover - ajax call");
//

var
ajaxPanel = window["RadAjaxPanel1"]; ajaxPanel.AjaxRequestWithTarget(eventTarget, eventArgument);

}

I am at a loss now,..C# and js seem to be accurate word for word
Attached is the form
TIA
Neal

<%

@ Page Language="c#" Inherits="DefaultCS" CodeFile="DefaultCS.aspx.cs" %>

<%

@ Register TagPrefix="rada" Namespace="Telerik.WebControls" Assembly="RadAjax.Net2" %>

<%

@ Register TagPrefix="radT" Namespace="Telerik.WebControls" Assembly="RadTreeView.Net2" %>

<%

@ Register TagPrefix="radG" Namespace="Telerik.WebControls" Assembly="RadGrid.Net2" %>

 

 

<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<

HTML>

 

<HEAD>

 

<link href="StyleSheet.css" rel="stylesheet" type="text/css">

 

<script type="text/javascript" src="dragdrop.js"></script>

 

</HEAD>

 

<body onload="enabledragdrop();">

 

<form id="form1" runat="server">

 

<rada:RadAjaxPanel ID="RadAjaxPanel1" runat="server"

BorderColor="Silver"

BorderStyle="Solid"

BorderWidth="1px">

 

<table width="100%" height="100%">

 

<tr>

 

<td colspan="2" height="450px"

 

class="OutlookTopBarWide" valign="top">

My Files

<radG:RadGrid ID="Grid1" runat="server" Skin="none"

 

height="100%"

 

AllowPaging="True"

 

AllowSorting="False"

 

AutoGenerateColumns="False"

 

PageSize="25" Width="100%"

 

GridLines="Horizontal"

OnNeedDataSource="grid1_needdata">

 

<PagerStyle Height="22px"

CssClass="GridPager"

Mode="NumericPages"></PagerStyle>

 

<HeaderStyle VerticalAlign="Middle"

HorizontalAlign="Left" Height="20px"

CssClass="OutlookHeader"

 

BackColor="Control"></HeaderStyle>

 

<ItemStyle CssClass="Gridrow"></ItemStyle>

 

<AlternatingItemStyle CssClass="GridAltRow"></AlternatingItemStyle>

 

<MasterTableView

DataKeyNames="FolderID" >

 

<Columns>

 

<radG:GridBoundColumn DataField="Name"

HeaderText="Name" UniqueName="Name">

 

</radG:GridBoundColumn>

 

<radG:GridBoundColumn DataField="Size"

HeaderText="Len" UniqueName="Len">

 

</radG:GridBoundColumn>

 

<radG:GridBoundColumn DataField="DateModified"

HeaderText="DateModified" UniqueName="DateModified">

 

</radG:GridBoundColumn>

 

</Columns>

 

</MasterTableView>

 

<ClientSettings >

 

<ClientEvents OnRowCreated="RowCreated"></ClientEvents>

 

</ClientSettings>

 

</radG:RadGrid>

 

</td>

 

</tr>

 

<tr>

 

<td colspan="2" >&nbsp Server File Explorer</td>

 

</tr>

 

<tr>

 

<td valign="top" class="OutlookTopBar" width="250" height="320">

 

Server Folders

<radT:RadTreeView

ID="RadTree1"

AutoPostBack="True"

Runat="server"

Width="250px" Height="320px"

AfterClientHighlight="SetTreeDropNode"

OnNodeClick="RadTree1_NodeClick"

OnNodeExpand="RadTree1_NodeExpand" />

 

</td>

 

<td valign="top" class="OutlookTopBar" style="width: 360px"> Server Files

<radG:RadGrid ID="Grid2" runat="server" Skin="none"

 

CssClass="RadGrid"

 

AllowPaging="True"

 

AllowSorting="False"

 

AutoGenerateColumns="False"

 

PageSize="25" Width="100%"

 

GridLines="Horizontal"

OnNeedDataSource="grid1_needdata">

 

<PagerStyle Height="22px"

CssClass="GridPager"

Mode="NumericPages"></PagerStyle>

 

<HeaderStyle Font-Size="11px" Font-Names="Arial"

HorizontalAlign="Left" Height="22px"

CssClass="OutlookHeader"

BackColor="Control"></HeaderStyle>

<ItemStyle CssClass="Gridrow"></ItemStyle>

<AlternatingItemStyle CssClass="GridAltRow"></AlternatingItemStyle>

<MasterTableView

DataKeyNames="FolderID" >

<Columns>

<radG:GridBoundColumn DataField="Name"

HeaderText="Name" UniqueName="Name">

</radG:GridBoundColumn>

<radG:GridBoundColumn DataField="Size"

HeaderText="Len" UniqueName="Len">

</radG:GridBoundColumn>

 

<radG:GridBoundColumn DataField="DateModified"

HeaderText="DateModified" UniqueName="DateModified">

</radG:GridBoundColumn>

</Columns>

</MasterTableView>

 

<ClientSettings >

<ClientEvents OnRowCreated="RowCreated"></ClientEvents>

</ClientSettings>

</radG:RadGrid>

</tr>

</table>

</rada:RadAjaxPanel></form></body>

</

HTML>

js
====

var

currentRow, movedRow = null;

var

isMouseOver = 0;

var

radGridOver = "";

var

isDragDropEnabled = false;

function

drover(dr)

{

radGridOver =

"DeleteRow";

dr.style.border =

"solid 2px #666";

dr.style.padding =

"1px";

};

function

drout(dr)

{

radGridOver =

"";

dr.style.border =

"solid 1px #666";

dr.style.padding =

"2px";

};

function

enabledragdrop()

{

//this is to prevent errors when you start dragging items

//before the page is completely loaded

isDragDropEnabled =

true;

};

function

RowCreated(row)

{

var mouseDownHandler = function(e)

{

if (!isDragDropEnabled)

return;

if (!e)

var e = window.event;

if (!currentRow)

{

currentRow = document.createElement(

"DIV");

currentRow.innerHTML =

"<table class='RadGrid' width='100%'><tbody><tr>"+row.Control.innerHTML+"</tr></tbody><table>";

document.body.appendChild(currentRow);

currentRow.style.position =

"absolute";

currentRow.style.display =

"none";

movedRow = row;

}

ClearDocumentEvents();

};

var mouseUpHandler = function(e)

{

if (!e)

var e = window.event;

//window.alert("mouseUp");

if (currentRow)

{

//window.alert("currentow");

if (movedRow && currentRow.style.display != "none")

{

if(movedRow.Owner)

{

movedRow.Owner.SelectRow(movedRow.Control,

true);

//window.alert("targeting");

var target = e.srcElement || e.target;

var destinationRowIndex = target.parentNode.rowIndex - 1; // insert before

if (isNaN(destinationRowIndex)) //if there are no records in the grid

{

destinationRowIndex = 0;

}

var eventTarget = movedRow.Owner.OwnerID;

var eventArgument = "RowMoved|" + movedRow.Owner.OwnerID + "," + movedRow.Index + "," + radGridOver + "," + destinationRowIndex;

//debug

window.alert(

"check radGridover = " + radGridOver +

" And , ..movedRow.Owner.OwnerID = " + movedRow.Owner.OwnerID );

if (radGridOver != "" && radGridOver != movedRow.Owner.OwnerID)

{

window.alert(

"radGridover - ajax call");

var ajaxPanel = window["RadAjaxPanel1"];

ajaxPanel.AjaxRequestWithTarget(eventTarget, eventArgument);

}

}

}

document.body.removeChild(currentRow);

currentRow =

null;

movedRow =

null;

}

RestoreDocumentEvents();

};

var mouseMoveHandler = function(e)

{

if (!e)

var e = window.event;

if (currentRow)

{

currentRow.style.display =

"block";

currentRow.style.backgroundImage =

"url(Img/rowBg.gif)";

currentRow.style.height =

"24px";

currentRow.style.width =

"48%";

currentRow.style.filter =

"progid:DXImageTransform.Microsoft.Alpha(style=1,opacity=80,finishOpacity=100,startX=100,finishX=100,startY=100,finishY=100)";

currentRow.style.MozOpacity =

".80";

currentRow.style.top = e.clientY +

document.documentElement.scrollTop +

document.body.scrollTop + 3 +

"px";

currentRow.style.left = e.clientX +

document.documentElement.scrollLeft +

document.body.scrollLeft + 3 +

"px";

}

};

var mouseOverHandler = function(e)

{

if (!e)

var e = window.event;

var parentEl;

if(e.srcElement) //IE

{

//debug

window.alert(

"ParentE1 = " + parentEl.id);

parentEl = e.srcElement;

while (parentEl && parentEl.className != "RadGrid" && parentEl.id != "DeleteRow")

{

parentEl = parentEl.parentElement;

}

}

else //gecko browsers

{

parentEl = e.target;

while (parentEl && parentEl.className != "RadGrid" && parentEl.id != "DeleteRow")

{

parentEl = parentEl.parentNode;

}

}

//debug

window.alert(

"ParentE1 = " + parentEl.id);

if (parentEl)

radGridOver = parentEl.id;

if ("" != radGridOver)

{

document.getElementById(radGridOver+

"_head").style.color = "gray";

}

isMouseOver++;

};

var mouseOutHandler = function(e)

{

if (!e)

var e = window.event;

isMouseOver--;

if (0 == isMouseOver)

{

if ("" != radGridOver)

{

document.getElementById(radGridOver+

"_head").style.color= "black";

}

radGridOver =

"";

}

};

if (row.ItemType == "Item" || row.ItemType == "AlternatingItem")

{

row.Control.style.cursor =

"move";

if (row.Control.attachEvent)

{

row.Control.attachEvent(

"onmousedown", mouseDownHandler);

document.body.attachEvent(

"onmousemove", mouseMoveHandler);

}

if (row.Control.addEventListener)

{

row.Control.addEventListener(

"mousedown", mouseDownHandler, false);

document.body.addEventListener(

"mousemove", mouseMoveHandler, false);

}

}

if (row.Control.attachEvent)

{

document.body.attachEvent(

"onmouseup", mouseUpHandler);

row.Owner.Owner.Control.attachEvent(

"onmouseover", mouseOverHandler);

row.Owner.Owner.Control.attachEvent(

"onmouseout", mouseOutHandler);

}

if (row.Control.addEventListener)

{

document.body.addEventListener(

"mouseup", mouseUpHandler, false);

row.Owner.Owner.Control.addEventListener(

"mouseover", mouseOverHandler, false);

row.Owner.Owner.Control.addEventListener(

"mouseout", mouseOutHandler, false);

}

};

function

ClearDocumentEvents()

{

if (document.onmousedown != this.mouseDownHandler)

{

this.documentOnMouseDown = document.onmousedown;

}

if (document.onselectstart != this.selectStartHandler)

{

this.documentOnSelectStart = document.onselectstart;

}

this.mouseDownHandler = function(e){return false;};

this.selectStartHandler = function(){return false;};

document.onmousedown =

this.mouseDownHandler;

document.onselectstart =

this.selectStartHandler;

};

function

RestoreDocumentEvents()

{

if ((typeof(this.documentOnMouseDown) == "function") &&

(document.onmousedown !=

this.mouseDownHandler))

{

document.onmousedown =

this.documentOnMouseDown;

}

else

{

document.onmousedown =

"";

}

if ((typeof(this.documentOnSelectStart) == "function") &&

(document.onselectstart !=

this.selectStartHandler))

{

document.onselectstart =

this.documentOnSelectStart;

}

else

{

document.onselectstart =

"";

}

};


C#
===

using

System;

using

System.Data;

using

System.Configuration;

using

System.Web.Configuration;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Web.UI.HtmlControls;

using

System.IO;

using

Telerik.WebControls;

using

System.Collections;

 

///

<summary>

///

The following allows a User to see the files in a "local Files Grid" per the selected

///

DM or Roleplayer.

///

..this is loaded at Page_Load, using a Dir explorer, given the required folder path.

///

..(ex the Config File..keyed per their ID)

///

///

A Server Folder Explorer allows browsing (pre-set/configured paths) for

///

folders + files on the Server, from which files can be dragged n dropped onto the

///

"local Files Grid"

///

The fso object is employed to do the physical file moving.

///

///

The drag n drop Grid refreshes required, are handled using an external js

///

and an overridden Raise Postback Event function

///

///

Code is in place to handle drag n drop from the Grid to the TreeView as well, but is not

///

a requirement of this Screen

///

</summary>

///

public partial class DefaultCS : System.Web.UI.Page

{

static int Id ;

private string ServerInitialDirectory;

private string LocalInitialDirectory;

#region

Server DataStructures/Properties/Persistance

public DataTable CurrentDir

{

get

{

return (DataTable)ViewState["CurrentDir"];

}

set

{

ViewState[

"CurrentDir"] = value;

}

}

public DataRow copiedGridItem

{

get

{

DataRow row = CurrentDir.NewRow();

if (ViewState["copiedGridItem_Name"] != null)

{

row[0] =

"Copy of " + ViewState["copiedGridItem_Name"];

row[1] = ViewState[

"copiedGridItem_Size"];

}

return row;

}

set

{

DataRow row = (DataRow)value;

ViewState[

"copiedGridItem_Name"] = row[0];

ViewState[

"copiedGridItem_Size"] = row[1];

}

}

 

//Server Folder

private string CurrFolder

{

get

{

object res = this.ViewState["CurrFolder"];

if ( res != null )

{

return (string)res;

}

return ServerInitialDirectory;

//return "Inbox";

}

set

{

this.ViewState["CurrFolder"] = value;

}

}

#endregion

#region

DragDrop Overridden PostbackEvents Manager

protected override void RaisePostBackEvent(IPostBackEventHandler sourceControl,

string eventArgument)

{

base.RaisePostBackEvent(sourceControl, eventArgument);

if (eventArgument != null)

{

if ((eventArgument.StartsWith("RowMoved")))

{

string[] args = eventArgument.Split('|')[1].Split(',');

RadGrid srcGrid = (RadGrid)this.FindControl(args[0]);

RadGrid destinationGrid = (RadGrid)this.FindControl(args[2]);

int srcRowIndex = srcGrid.CurrentPageIndex * srcGrid.PageSize + int.Parse(args[1]);

int destinationRowIndex = -1;

if ((!(destinationGrid == null)))

{

destinationRowIndex = destinationGrid.CurrentPageIndex * destinationGrid.PageSize +

int.Parse(args[3]);

}

if (srcRowIndex >= 0 & destinationRowIndex >= 0)

{

GridItem srcItem = srcGrid.Items[srcRowIndex];

GridItem dstItem = destinationGrid.Items[destinationRowIndex];

int srcKey = (int)srcGrid.MasterTableView.DataKeyValues[srcItem.ItemIndex]["FolderID"];

int dstKey = (int)destinationGrid.MasterTableView.DataKeyValues[dstItem.ItemIndex]["FolderID"];

DataRow row1;

DataRow row2;

DataRow newRow;

//swaping from grid1 to grid2

if (args[2] == Grid2.ID & srcRowIndex < Grid1Data.Rows.Count)

{

row1 =

this.Grid1Data.Select(string.Format("MailID = '{0}'", srcKey))[0];

row2 =

this.Grid2Data.Select(string.Format("MailID = '{0}'", dstKey))[0];

newRow =

this.Grid1Data.NewRow();

newRow.ItemArray = row1.ItemArray;

row1.ItemArray = row2.ItemArray;

row2.ItemArray = newRow.ItemArray;

}

//moving from "Grid2" to Grid1

if (args[2] == Grid1.ID & srcRowIndex < CurrentDir.Rows.Count)

{

row1 =

this.Grid2Data.Select(string.Format("FolderID = '{0}'", srcKey))[0];

row2 =

this.Grid1Data.Select(string.Format("FolderID = '{0}'", dstKey))[0];

//set newRow obj as a new row of Grid1 (Dest Grid), and set the row's Id for it

newRow =

this.Grid1Data.NewRow();

newRow.ItemArray = row1.ItemArray;

//Set Row of DestGrid = row of Source grid

row1.ItemArray = row2.ItemArray;

//Set SourceGrids Row = Dest Grids Row

//i.e. swops them out..

//row2.ItemArray = newRow.ItemArray;

}

//rebind grids after modifications

//Update this to the Server,...setting the ClientsDocuments table with

// the added File/Folder/Path+name, @date and by whom(session["UserId"])

//

Grid1.Rebind();

}

}

}

}

#endregion

protected void Page_Load(object sender, System.EventArgs e)

{

if(!IsPostBack)

{

Id = 0;

//ToDo: Per the Owner ID,...get their InitialFolder

LocalInitialDirectory =

WebConfigurationManager.AppSettings["InitialFolder"];

Grid1Data = GetFileOnlyList(LocalInitialDirectory);

ServerInitialDirectory =

WebConfigurationManager.AppSettings["DRM: InitialDocFolder"];

Grid2Data = GetFileOnlyList(ServerInitialDirectory);

//TreeView Load with Folders

Generate_TreeViewNNR(ServerInitialDirectory);

}

}

private string GetImageForExtension(string fileName)

{

string image = "File.gif";

switch (Path.GetExtension(fileName))

{

case ".txt":

image =

"cs.gif";

break;

case ".xls":

image =

"cs.gif";

break;

case ".pdf":

image =

"cs.gif";

break;

case ".doc":

image =

"cs.gif";

break;

case ".docx":

image =

"cs.gif";

break;

 

case ".cs":

image =

"cs.gif";

break;

case ".css":

image =

"css.gif";

break;

case ".html":

image =

"html.gif";

break;

case ".resx":

image =

"resx.gif";

break;

case ".vb":

image =

"vb.gif";

break;

case ".xml":

image =

"xml.gif";

break;

case ".ascx":

case ".aspx":

image =

"ascx.gif";

break;

case ".gif":

case ".jpg":

image =

"gif.gif";

break;

case "":

image =

"mailfolder.gif";

break;

}

return image;

}

private DataTable GetFileOnlyList(string directory)

{

//--------------------------------------------------------

// Creates a Collection of Files as a DataTable

// being source for the Grids

//--------------------------------------------------------

DataTable filesAndFolders = new DataTable();

filesAndFolders.Columns.Add(

"FolderId");

filesAndFolders.Columns.Add(

"Name");

filesAndFolders.Columns.Add(

"Size");

filesAndFolders.Columns.Add(

"DateModified");

if (directory != string.Empty)

{

DirectoryInfo dir = new DirectoryInfo(directory);

foreach (FileInfo file in dir.GetFiles())

{

Id += 1;

filesAndFolders.Rows.Add(

new string[] {Id.ToString(), file.Name, file.Length.ToString(),file.LastWriteTime.ToLongDateString() });

}

}

return filesAndFolders;

}

 

#region

LocalOwners FilesGrid GetData

public DataTable Grid1Data

{

get

{

return (DataTable)Session["_grid1Data"];

}

set

{

Session[

"_grid1Data"] = value;

}

}

protected void grid1_needdata(object source, GridNeedDataSourceEventArgs e)

{

Grid1.DataSource = Grid1Data;

//i.e GetFileListOnly(LocalInitialDirectory);

}

 

protected void Grid1_ItemDataBound(object sender, GridItemEventArgs e)

{

if (e.Item is GridDataItem)

{

try

{

System.Web.UI.WebControls.

Image icon = (System.Web.UI.WebControls.Image)e.Item.FindControl("icon");

icon.ImageUrl =

"ExplorerImages/" + GetImageForExtension((string)DataBinder.Eval(e.Item.DataItem, "Name"));

icon.AlternateText =

"icon";

icon.ImageAlign = System.Web.UI.WebControls.

ImageAlign.AbsMiddle;

icon.Style.Add(

"vertical-align", "middle");

icon.BorderWidth =

Unit.Pixel(0);

GridDataItem dataItem = (GridDataItem)e.Item;

string fileLength = (string)DataBinder.Eval(e.Item.DataItem, "Size");

if (fileLength != "-1")

dataItem[

"Size"].Text = fileLength;

else

dataItem[

"Size"].Text = " ";

//Extra code to do stuff for DateModified, ByWhomModified etc

}

catch (Exception ex)

{

Session[

"ErrMsg"] = ex.Message;

Response.Redirect(

"ErrPage.aspx");

}

}

}

#endregion

 

#region

Grid2

public DataTable Grid2Data

{

get

{

return (DataTable)Session["_grid2Data"];

}

set

{

Session[

"_grid2Data"] = value;

}

}

public void grid2_needdata(object source, Telerik.WebControls.GridNeedDataSourceEventArgs e)

{

Grid2.DataSource = Grid2Data;

}

protected void Grid2_ItemDataBound(object sender, GridItemEventArgs e)

{

if (e.Item is GridDataItem)

{

try

{

System.Web.UI.WebControls.

Image icon = (System.Web.UI.WebControls.Image)e.Item.FindControl("icon");

icon.ImageUrl =

"ExplorerImages/" + GetImageForExtension((string)DataBinder.Eval(e.Item.DataItem, "Name"));

icon.AlternateText =

"icon";

icon.ImageAlign = System.Web.UI.WebControls.

ImageAlign.AbsMiddle;

icon.Style.Add(

"vertical-align", "middle");

icon.BorderWidth =

Unit.Pixel(0);

GridDataItem dataItem = (GridDataItem)e.Item;

string fileLength = (string)DataBinder.Eval(e.Item.DataItem, "Size");

if (fileLength != "-1")

dataItem[

"Size"].Text = fileLength;

else

dataItem[

"Size"].Text = " ";

}

catch (Exception ex)

{

Session[

"ErrMsg"] = ex.Message;

Response.Redirect(

"ErrPage.aspx");

}

}

}

#endregion

 

#region

TreeView Explorer

private void Generate_TreeViewNNR(string folder)

{

RadTreeNode rootNode = new RadTreeNode(ServerInitialDirectory);

rootNode.ImageUrl =

"ExplorerImages/mailfolder.gif";

rootNode.Expanded =

true;

rootNode.Category =

"Folder";

rootNode.Value = folder;

rootNode.ContextMenuName =

"File";

RadTree1.Nodes.Add(rootNode);

//This gets the Files per the Folder(Initial or Clicked)

// and loads it into the local DataTable

// CurrentDir = GetFileList(folder);

//Loads the TreeView with Folders from Dir.getDirectories

LoadTreeView(folder, rootNode.Nodes);

}

private DataTable GetFileList(string directory)

//------------------------------------------------------------------

// Creates a Collection of Files and Folders , returns it as DTable

// for the TreeView (the Grids use GetFileListOnly)

//-------------------------------------------------------------------

{

DataTable filesAndFolders = new DataTable();

filesAndFolders.Columns.Add(

"Name");

filesAndFolders.Columns.Add(

"Size");

if (directory != string.Empty)

{

DirectoryInfo dir = new DirectoryInfo(directory);

foreach (DirectoryInfo subDir in dir.GetDirectories())

{

filesAndFolders.Rows.Add(

new string[] { subDir.Name, "-1" });

}

foreach (FileInfo file in dir.GetFiles())

{

filesAndFolders.Rows.Add(

new string[] { file.Name, file.Length.ToString() });

}

}

return filesAndFolders;

}

private void LoadTreeView(string dirPath, RadTreeNodeCollection collection)

//--------------------------------------------------------

// Loads the TreeView with the dirs, stores in local collection

//--------------------------------------------------------

{

if (dirPath == string.Empty)

return;

string[] dirs = Directory.GetDirectories(dirPath);

foreach (string path in dirs)

{

string[] parts = path.Split('\\');

string name = parts[parts.Length - 1];

RadTreeNode node = new RadTreeNode(name);

node.ImageUrl =

"ExplorerImages/mailfolder.gif";

node.Value = path;

node.ContextMenuName =

"File";

node.Category =

"Folder";

if (Directory.GetDirectories(path).Length > 0)

{

node.ExpandMode =

ExpandMode.ServerSide;

}

collection.Add(node);

}

}

 

#endregion

protected void RadTree1_NodeClick(object o, RadTreeNodeEventArgs e)

{

RadTreeNode NodeClicked = e.NodeClicked;

if (RadTree1.SelectedNodes.Count == 1)

{

if (this.CurrFolder != NodeClicked.Text.ToString())

{

//The Folder Structure must include the whole Path....

//

this.CurrFolder = NodeClicked.Value; //The path is stored here

//this.CurrFolder = NodeClicked.Text.ToString();

Grid2.CurrentPageIndex = 0;

Grid2.Rebind();

}

}

}

protected void RadTree1_NodeExpand(object o, RadTreeNodeEventArgs e)

{

RadTreeNode NodeClicked = e.NodeClicked;

//Get the Sub Folders if any, + files,..and into Grid

string folder = NodeClicked.Value;

CurrentDir = GetFileList(folder);

//Loads the TreeView with Folders from Dir.getDirectories

LoadTreeView(folder, NodeClicked.Nodes);

GetFileList(folder);

}

protected void GoToNoRecords(object sender, EventArgs e)

{

this.CurrFolder = ServerInitialDirectory;

Grid2.CurrentPageIndex = 0;

Grid2.Rebind();

RadTree1.FindNodeByText(

this.CurrFolder).Selected = true;

}

#region

Web Form Designer generated code

override protected void OnInit(EventArgs e)

{

//

// CODEGEN: This call is required by the ASP.NET Web Form Designer.

//

InitializeComponent();

base.OnInit(e);

}

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent()

{

//We added the RadTree NodeClick event so we get a POSTBACK action on the NodeSelect command when it

//is called on the clientSide.

this.RadTree1.NodeClick += new Telerik.WebControls.RadTreeView.RadTreeViewEventHandler(this.RadTree1_NodeClick);

this.Grid2.NeedDataSource += new Telerik.WebControls.GridNeedDataSourceEventHandler(this.grid2_needdata);

//this.PreRender += new System.EventHandler(this.grid_PreRender);

}

#endregion

}

 

5 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 14 May 2008, 01:07 PM
Hi Neal,

I am not sure what you would like to achieve with this javascript approach, however the drag and drop functionality is already built-in for our ASP.NET AJAX grid. Review the online resources linked below for further details:

http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/Programming/DragAndDrop/DefaultCS.aspx
http://www.telerik.com/help/aspnet-ajax/drag-drop-grid-items.html

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Neal
Top achievements
Rank 1
answered on 14 May 2008, 01:56 PM
Hi Steven,

The Client events for this Q12008 release ...sure,..
But,..
I am using Q1 2007 for aspnET2, and the solution JScript et al is a direct copy of the drag n drop solution from Telerik about a month ago.

The Link Was./is
http://www.telerik.com/community/code-library/submission/b311D-gamta.aspx

and the Download file was  056003_DragDrop-Modified.zip 

TIA
Neal
0
Rosen
Telerik team
answered on 17 May 2008, 07:40 AM
Hello Neal,

Unfortunately I was unable to reproduce the behavior you are describing. Therefore if you can please approve us with detailed, step-by-step description of how to recreate this unwanted behavior it will be highly appreciated. 

Kind regards,
Rosen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Neal
Top achievements
Rank 1
answered on 19 May 2008, 08:48 AM

Hi

I submitted my jsp and forms and comments and indications of the problem in the post preceding the last one.

Are you testing those or the downloaded demo from Telerik?

The problem is in the jsp when determining ...If (!e) on the 
mouseUpHandler event in dragdrop.js fires,
the  radGridOver var is empty, so no Ajax postback.
I tracked it to the mouseOverHandler(var mouseOverHandler = function(e))

and after the check for IE it seems to exit, as the debug window.alert does not fire..

var mouseOverHandler = function(e)
{
   if (!e)
        var e = window.event;

  
var parentEl;
   if(e.srcElement) //IE
   {
       //debug ..Problem is here,..this alert window does not fire
       window.alert("ParentE1 = " + parentEl.id);
        parentEl = e.srcElement;

//and......as a result
  //debug  ...this alert showsradGridOver as empty string
     window.alert("check radGridover = " + radGridOver + " And , ..movedRow.Owner.OwnerID = " + movedRow.Owner.OwnerID );

if (radGridOver != "" && radGridOver != movedRow.Owner.OwnerID)
{
   //debug  ...this alert thus does not fire,..no Drop no Ajax 
    Callback, ...

      window.alert(
"radGridover - ajax call"); 



Steven, ..If I can attach (somehow??) the project (zipped) 
Telerik V 1.6 aspnet.2 ...Q4 1006
TIA

 

Steven, ..If I can attach (somehow??) the project (zipped) Telerik V 1.6 aspnet.2 ...Q4 1006TIA

0
Vlad
Telerik team
answered on 19 May 2008, 03:09 PM
Hi Neal,

You can open a support ticket and attach the project.

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Neal
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Neal
Top achievements
Rank 1
Rosen
Telerik team
Vlad
Telerik team
Share this question
or