Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
141 views
I'm having an issue embedding a RadMenu within a RadGrid cell.  Its within a TemplateColumn and binds correctly through the ItemDatabound event, but there's something off on the rendering. 

I've got scrolling enabled, but the RadMenus render past the defined boundaries of the RadGrid.  The same effect can be seen by adding standard ASP Button controls instead.  I changed the RadGrid back to the RadControls ASP.NET Q1-2008 as a fix for now.. is there a fix for this?
Dimo
Telerik team
 answered on 19 May 2008
1 answer
161 views
I am trying to show and image only on row mouse over.  and once the row is click(as stated above), keep this picture showing.  onrowmouseout, the image would disappear.  Not just mousing over the image, but mouse over the row.  Any help would be greatly appreciated.

Thanks for you help.

Joshua
Dimo
Telerik team
 answered on 19 May 2008
4 answers
189 views
I'm using a combobox with telerik skin for filtering in my radgrid.  Using IE 7, each combobox shows vertical & hortizonal scrollbars whether they are necessary or not.  I am setting the dropdownlistwidth property that should ensure my users don't have to scroll - the horizontal scroll shows up no matter what.  Also, the vertical scroll always shows up always hiding the last item in the list - even when the list only has 2 items. 

The same code works perfectly in FF, so I'm sure it's a css problem in the skin.  I've tried a few other skins in IE and still get the weird scrolling.  Any chance this is any easy fix in the css?  I plan to create a custom skin so hopefully this is an easy item to address. 
debbie f
Top achievements
Rank 1
 answered on 19 May 2008
5 answers
300 views
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

}

 

Vlad
Telerik team
 answered on 19 May 2008
1 answer
146 views
Hi,
  How to get the selectedIndex of the

telerik

:RadComboBox

 using javascript on a click of a button.


Thanks.
Raju.
Rosi
Telerik team
 answered on 19 May 2008
1 answer
84 views
Hello,

    I have 3 user controls, each user control contains a radgrid.
user control  on seprate pages works fine. But when i put all 3 uc on a single page it works on IE but not on firefox. On Firefox it shows only first grid of first uc.

please help.



Thank's
Monika
Veli
Telerik team
 answered on 19 May 2008
1 answer
84 views
Hi,

I've noticed an intermittant problem with RadEditor in IE7, namely that quite often, when the RadEditor is loaded, the toolbars don't display - you just see the left-hand edge of each toolbar but no buttons etc.

Sometimes a refresh will sort this, but other times you have to close the browser and re-open it and try again.

I don't see this problem in Firefos or Opera or Safari.

Anybody else had this?

Thanks,

Matt
Dimcho
Telerik team
 answered on 19 May 2008
1 answer
132 views
Hi,

In Prometheus RadEditor, where I use Image manager tool, I randomly get an error, where in Image Upload dialog box I'm not getting the upload button itself. It's just not there. What I've noticed is, that when I move the dialog box (dragging it a bit on the screen and then releasing it) the upload button appears (along with cancel link).
Is there some way how to work around this random misbehaviour, please?
Thanks

Adrian
George
Telerik team
 answered on 19 May 2008
5 answers
160 views
hi

i just found out that the rad controls behave differently with each different browser. By far, firefox works perfectly.

While using IE 6, not too bad, just that sometime you can see the whole page is refresh when you know that the page has ajax enable. IE7 is the worst, every page refreshes and also the gird does not work well with IE7. Are there any way i can overcome the IE7 issues? Thanks
Maria Ilieva
Telerik team
 answered on 19 May 2008
1 answer
70 views

Hi

I have a web form with a button to show a modal window.  I was able to move the window by dragging the window's title bar up above the content area of the IE browser so the title bar is hidden so I cannot grab it to move it back.  Is there a way to prevent this?

Thank you,

Vincent

Georgi Tunev
Telerik team
 answered on 19 May 2008
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?