14 Answers, 1 is accepted
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
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
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,
the telerik team
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:
|
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 >
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:
|
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 >
I forgot to mention that I'm not using the Portal just the Services, would that make difference.
Thanks
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
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:
|
Source File: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\Template\1033\STS\Lists\doclib\AllItems.aspx Line: 34
Stack Trace:
|
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
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
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.