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

Treeview

14 Answers 186 Views
RadEditor
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Marcia Marino
Top achievements
Rank 1
Marcia Marino asked on 15 Aug 2006, 05:42 AM
Is there a sample how to use the treeview on SharePoint 2003?

14 Answers, 1 is accepted

Sort by
0
Dimitar Milushev
Telerik team
answered on 15 Aug 2006, 09:39 AM


Hi Marcia,

You need to create a custom WebPart that includes an instance of the treeview and populates it. Here are two links that should get you started with the WebPart creation - http://msdn.microsoft.com/office/default.aspx?pull=/library/en-us/dnofftalk/html/office07012004.asp and http://www.devx.com/dotnet/Article/17518/0/page/1

As far as the r.a.d.treeview code is concerned, you can have a look at the online examples www.telerik.com/r.a.d.treeview.
For a start, you should override the CreateChildControls method of the WebPart. Inside the method, create and populate the treeview. Here is a simple example that creates a treeview with one parent node and one child node:

protected override void CreateChildControls()  
{  
    RadTreeView treeView = new RadTreeView();  
 
    treeView.ID = "radTreeView";  
 
    RadTreeNode parentNode = new RadTreeNode();  
    parentNode.Text = "Parent";  
      
    treeView.Nodes.Add(parentNode);  
      
    RadTreeNode childNode = new RadTreeNode();  
    childNode.Text = "Child";  
 
    parentNode.Nodes(Add(childNode);  
 
    Controls.Add(treeView);  
    base.CreateChildControls();  

I should mention that we will be releasing navigation WebParts for SharePoint soon, including one using r.a.d.treeview. If you want to replace the default SharePoint navigation, the new WebParts should prove very helpful.

Sincerely yours,
Digibo
the telerik team
0
Marcia Marino
Top achievements
Rank 1
answered on 15 Aug 2006, 10:30 PM
Thanks, has anyone try to query the document library. I'm having problems.
0
Marcia Marino
Top achievements
Rank 1
answered on 16 Aug 2006, 07:21 PM

Ok I can query sharepoint, but I'm get a permission error from share point. I have coment all my code and now I'm just declaring the tree and still getting same error.

using System;

using System.ComponentModel;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Xml.Serialization;

using Microsoft.SharePoint;

using Microsoft.SharePoint.Utilities;

using Microsoft.SharePoint.WebPartPages;

using Telerik.WebControls;

namespace OrgMenu

{

/// <summary>

/// Description for WebPart1.

/// </summary>

[DefaultProperty("Text"),

ToolboxData("<{0}:WebPart1 runat=server></{0}:WebPart1>"),

XmlRoot(Namespace="OrgMenu")]

public class WebPart1 : Microsoft.SharePoint.WebPartPages.WebPart

{

private const string defaultText = "";

private string text = defaultText;

[Browsable(true),

Category("Miscellaneous"),

DefaultValue(defaultText),

WebPartStorage(Storage.Personal),

FriendlyName("Text"),

Description("Text Property")]

public string Text

{

get

{

return text;

}

set

{

text = value;

}

}

/// <summary>

/// This method gets the custom tool parts for this Web Part by overriding the

/// GetToolParts method of the WebPart base class. You must implement

/// custom tool parts in a separate class that derives from

/// Microsoft.SharePoint.WebPartPages.ToolPart.

/// </summary>

///<returns>An array of references to ToolPart objects.</returns>

// public override ToolPart[] GetToolParts()

// {

// ToolPart[] toolparts = new ToolPart[2];

// WebPartToolPart wptp = new WebPartToolPart();

// CustomPropertyToolPart custom = new CustomPropertyToolPart();

// toolparts[0] = wptp;

// toolparts[1] = custom;

// return toolparts;

// }

 

// protected OrgMenu.LMCreateChildControls lmtreenav;

protected override void CreateChildControls()

{

 

RadTreeView treeView = new RadTreeView();

 

this.Controls.Add(treeView);

base.CreateChildControls();

}

//

/// <summary>

/// Render this Web Part to the output parameter specified.

/// </summary>

/// <param name="output"> The HTML writer to write out to </param>

protected override void RenderWebPart(HtmlTextWriter output)

{

this.EnsureChildControls();

this.RenderControl(output);

}

 

}

}

I Have add RadControls to Virtual Directory, DLL is on BIN folder.
What Am I missing?

Would be better to call it from ASCX control?

Thanks

0
Dimitar Milushev
Telerik team
answered on 17 Aug 2006, 07:59 AM


Hi Marcia,

Try setting the trust level to full. To do this, open Sharepoint's web.config file (usually found in c:\inetpub\wwwroot) and set the level attribute of the <trust> tag to "Full" like this:

<trust level="Full" originUrl="" />

Also make sure there is an entry for your WebPart in the <SafeControls> in web.config.

All the best,

Digibo
the telerik team
0
Marcia Marino
Top achievements
Rank 1
answered on 29 Aug 2006, 10:54 PM

Still having problems,

 

I have created a CustomTrust file for share point and add

<PermissionSet class="NamedPermissionSet" version="1" Name="CustomTrust">

<IPermission class="System.Web.AspNetHostingPermission, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

version="1" Level="Medium" />

<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

version="1" Flags="Execution" />

<IPermission class="Microsoft.SharePoint.Security.WebPartPermission, Microsoft.SharePoint.Security, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

version="1" Connections="True" />

<IPermission class="Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

version="1" ObjectModel="True" />

<IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

version="1" Read="$AppDir$" Write="$AppDir$" Append="$AppDir$" PathDiscovery="$AppDir$" />

</PermissionSet>

Under the namepermissions tag.
Trying to run just the sample code given by you nothing else but I get the error.


Exception Details: System.Security.SecurityException: Request for the permission of type System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SecurityException: Request for the permission of type System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.]
   System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet grantedSet, PermissionSet deniedSet, CodeAccessPermission demand, PermissionToken permToken) +675
   System.Security.CodeAccessSecurityEngine.Check(PermissionToken permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 checkFrames, Int32 unrestrictedOverride) +0
   System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark) +88
   System.Security.CodeAccessPermission.Demand() +62
   System.Reflection.Assembly.VerifyCodeBaseDiscovery(String codeBase) +121
   System.Reflection.Assembly.GetName(Boolean copiedName) +69
   System.Reflection.Assembly.GetName() +6
   Telerik.RadTreeviewUtils.ControlVersion..ctor() +50
   Telerik.RadTreeviewUtils.RadControl..cctor() +20


I'm using the version 1.1, and the tree dll on on the bin folder and I have RadControls as a virtual directory

I also have add this to the group tag

<CodeGroup

class="UnionCodeGroup"

version="1"

PermissionSetName="CustomTrust">

<IMembershipCondition

class="UrlMembershipCondition"

version="1"

Url="$AppDirUrl$/bin/RadTreeView.dll"

/>

<IMembershipCondition

class="UrlMembershipCondition"

version="1"

Url="$AppDirUrl$/bin/MavTree.dll"

/>

</CodeGroup>

<CodeGroup >

0
Marcia Marino
Top achievements
Rank 1
answered on 29 Aug 2006, 10:54 PM

Still having problems,

 

I have created a CustomTrust file for share point and add

<PermissionSet class="NamedPermissionSet" version="1" Name="CustomTrust">

<IPermission class="System.Web.AspNetHostingPermission, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

version="1" Level="Medium" />

<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

version="1" Flags="Execution" />

<IPermission class="Microsoft.SharePoint.Security.WebPartPermission, Microsoft.SharePoint.Security, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

version="1" Connections="True" />

<IPermission class="Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

version="1" ObjectModel="True" />

<IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

version="1" Read="$AppDir$" Write="$AppDir$" Append="$AppDir$" PathDiscovery="$AppDir$" />

</PermissionSet>

Under the namepermissions tag.
Trying to run just the sample code given by you nothing else but I get the error.


Exception Details: System.Security.SecurityException: Request for the permission of type System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SecurityException: Request for the permission of type System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.]
   System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet grantedSet, PermissionSet deniedSet, CodeAccessPermission demand, PermissionToken permToken) +675
   System.Security.CodeAccessSecurityEngine.Check(PermissionToken permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 checkFrames, Int32 unrestrictedOverride) +0
   System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark) +88
   System.Security.CodeAccessPermission.Demand() +62
   System.Reflection.Assembly.VerifyCodeBaseDiscovery(String codeBase) +121
   System.Reflection.Assembly.GetName(Boolean copiedName) +69
   System.Reflection.Assembly.GetName() +6
   Telerik.RadTreeviewUtils.ControlVersion..ctor() +50
   Telerik.RadTreeviewUtils.RadControl..cctor() +20


I'm using the version 1.1, and the tree dll on on the bin folder and I have RadControls as a virtual directory

I also have add this to the group tag

<CodeGroup

class="UnionCodeGroup"

version="1"

PermissionSetName="CustomTrust">

<IMembershipCondition

class="UrlMembershipCondition"

version="1"

Url="$AppDirUrl$/bin/RadTreeView.dll"

/>

<IMembershipCondition

class="UrlMembershipCondition"

version="1"

Url="$AppDirUrl$/bin/MavTree.dll"

/>

</CodeGroup>

<CodeGroup >

0
Marcia Marino
Top achievements
Rank 1
answered on 29 Aug 2006, 11:09 PM

I forgot to mention that I'm not using the Portal just the Services, would that make difference.

 

Thanks

0
Lini
Telerik team
answered on 30 Aug 2006, 03:31 PM
Hello Marcia,

Did you try just adding the treeview in the GAC? This should help since adding an assembly to the GAC basically equals Full trust for that assembly.

Also do not forget to do an iisreset after you modify the trust level for the SharePoint site.

Regards,
Lini
the telerik team
0
Marcia Marino
Top achievements
Rank 1
answered on 31 Aug 2006, 06:30 PM

OK my bos does not want me to add the tree to GAC, I was able to run the given sample I receive here, by creating a Custom config file, now that I'm trying to query Share point I get the following error.

 

Exception Details: System.Exception: You need to set an ID for r.a.d.treeview

Source Error:

Line 32: <BODY marginwidth=0 marginheight=0 scroll="yes">
Line 33:     <TABLE class="ms-main" CELLPADDING=0 CELLSPACING=0 BORDER=0 WIDTH="100%" HEIGHT="100%">
Line 34:     <form runat="server">
Line 35:     <!-- Banner -->
Line 36: <TR> 

Source File: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\Template\1033\STS\Lists\doclib\AllItems.aspx    Line: 34

Stack Trace:

[Exception: You need to set an ID for r.a.d.treeview]
   Telerik.WebControls.RadTreeView.Render(HtmlTextWriter output) +1331
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
   NavTree.LMTreeNav.RenderWebPart(HtmlTextWriter output)
   Microsoft.SharePoint.WebPartPages.WebPart.b(HtmlTextWriter A_0) +232
   Microsoft.SharePoint.WebPartPages.WebPart.Render(HtmlTextWriter writer) +33
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
   System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +44
   System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +262
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
   ASP.AllItems_aspx.__Render__control1(HtmlTextWriter __output, Control parameterContainer) in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\Template\1033\STS\Lists\doclib\AllItems.aspx:34
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +27
   System.Web.UI.Control.Render(HtmlTextWriter writer) +7
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
   System.Web.UI.Page.ProcessRequestMain() +1926

0
Atanas Korchev
Telerik team
answered on 01 Sep 2006, 06:52 AM
Hi Marcia,

As stated in the exception r.a.d.treeview requires its ID property to be explicitly set. Please set it to some value e.g. "treeView" and everything should work as expected.
protected override void CreateChildControls()   
{   
  RadTreeView treeView = new RadTreeView();   
  treeView.ID = "treeView"; 
  this.Controls.Add(treeView);   
  base.CreateChildControls();  
}  
 

Regards,
Albert
the telerik team
0
Marcia Marino
Top achievements
Rank 1
answered on 22 Sep 2006, 01:48 AM
I was able to create the part on development and have been working fine, now I deployed to production an I get a error message "RadTreeView" is undefined, it get filled it does not display the images or the tree fomat for that matter.
0
Atanas Korchev
Telerik team
answered on 22 Sep 2006, 08:26 AM
Hello Marcia,

You have probably not set up your production environment like your development one. The "RadTreeView is undefined" error is likely to happen if you have not copied the RadControls folder right or you have not excluded it from SharePoint managed paths using stsadm.exe -addpath. Please make sure the changes made to your dev environment are applied to your production server.

Regards,
Albert
the telerik team
0
Marcia Marino
Top achievements
Rank 1
answered on 22 Sep 2006, 04:18 PM

Yes I did, create the folder under the web root, create the virtual directory, change on the config file, place the DLL on the bin folder.

Restarted IIS.

0
Marcia Marino
Top achievements
Rank 1
answered on 22 Sep 2006, 09:28 PM
Thanks that work, well I'm live know.
Tags
RadEditor
Asked by
Marcia Marino
Top achievements
Rank 1
Answers by
Dimitar Milushev
Telerik team
Marcia Marino
Top achievements
Rank 1
Lini
Telerik team
Atanas Korchev
Telerik team
Share this question
or