We are using RadTreeView as a replacement for the menu in SharePoint. It is connecting to a datasource we have generated from the SPSites, basically creating a new SiteMapProvider. This is all in code behind. We have set the ExpandMode to "ServerSideCallBack" for efficiency reasons. But when I navigate to child sites, it doesn't show the currently selected node when the page is loaded......how can we achieve this???
please help
Snippets:
SharePoint MasterPage:
<%@ Master language="C#" Inherits="Chisholm.SharePoint.MasterPages.StudentPortal, Chisholm.SharePoint.MasterPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=36b5e3431f62f80f" %>
...........................................
<telerik:RadTreeView ID="myLearningTreeView" runat="server" Skin="Office2007"
DataSourceID="MyLearningDS"
OnNodeExpand="NodeExpandHandler"
MaxDataBindDepth="1"
DataNavigateUrlField="Url"
DataTextField="Title" DataValueField="Key" DataFieldID="Key" EnableEmbeddedSkins="False" SingleExpandPath="True">
<DataBindings>
<telerik:RadTreeNodeBinding ExpandMode="ServerSideCallBack" Depth="0" />
</DataBindings>
</telerik:RadTreeView>
<asp:SiteMapDataSource ID="MyLearningDS" runat="server"
ShowStartingNode="false"
StartFromCurrentNode="false"
StartingNodeOffset="0"
SiteMapProvider="MyPortalSiteMapProvider"
StartingNodeUrl="/myLearning"/>
............................
code behind: StudentPortal.cs
namespace
Chisholm.SharePoint.MasterPages
{
public class StudentPortal : MasterPage
{
protected global::Telerik.Web.UI.RadTreeView myLearningTreeView;
public RadTreeNode LastSelectedNode
{
get { return (RadTreeNode)ViewState["LastSelectedNode"]; }
set { ViewState["LastSelectedNode"] = value; }
}
public RadTreeView SiteMenu
{
get { return (RadTreeView)ViewState["SiteMenu"]; }
set { ViewState["SiteMenu"] = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
//if (!Page.IsPostBack)
//{
if ((SiteMenu!=null)&&(LastSelectedNode!=null))
{
// get the custom sql site map provider
SqlSiteMapProvider provider = ((SqlSiteMapProvider)SiteMap.Providers[
"MyPortalSiteMapProvider"]);
if (provider == null)
return;
// add a method to get chid nodes by Key
SiteMapNode siteNode = provider.FindSiteMapNodeFromKey(LastSelectedNode.Value);
if (siteNode == null)
return;
SiteMapNodeCollection childNodes = provider.GetChildNodes(siteNode);
if (childNodes.Count < 1)
return;
// NW: call FindSiteMapNodeFromKey() of the SiteMapProvider using
// the key obtained from the node that was clicked.
// The node that was clicked becomes the new parent of the children
// to be added to it from the database.
//
foreach (SiteMapNode child in childNodes)
{
// NW: The children are created based on the information obtained from
// the database.
//
// create a new node
RadTreeNode rtn =
new RadTreeNode()
{
Value = child.Key,
Text = child.Title,
ExpandMode = TreeNodeExpandMode.ServerSide,
//NW: This is overiden below.
NavigateUrl = child.Url,
LongDesc = child.Description
};
// with the same expand mode as the node currently expanding
rtn.ExpandMode = LastSelectedNode.ExpandMode;
// add the new node to the node that is expanding
LastSelectedNode.Nodes.Add(rtn);
}
// now that the nodes are added, change the current node's expand mode to client-side
LastSelectedNode.ExpandMode = TreeNodeExpandMode.ClientSide;
// signal that the node is now expanded
LastSelectedNode.Expanded =
true;
}
//}
}
protected void NodeExpandHandler(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
{
SiteMenu = (RadTreeView)sender;
LastSelectedNode = e.Node;
// get the custom sql site map provider
SqlSiteMapProvider provider = ((SqlSiteMapProvider)SiteMap.Providers[
"MyPortalSiteMapProvider"]);
if (provider == null)
return;
// add a method to get chid nodes by Key
SiteMapNode siteNode = provider.FindSiteMapNodeFromKey(e.Node.Value);
if (siteNode == null)
return;
SiteMapNodeCollection childNodes = provider.GetChildNodes(siteNode);
if (childNodes.Count < 1)
return;
// NW: call FindSiteMapNodeFromKey() of the SiteMapProvider using
// the key obtained from the node that was clicked.
// The node that was clicked becomes the new parent of the children
// to be added to it from the database.
//
foreach (SiteMapNode child in childNodes)
{
// NW: The children are created based on the information obtained from
// the database.
//
// create a new node
RadTreeNode rtn =
new RadTreeNode()
{
Value = child.Key, Text = child.Title,
ExpandMode = TreeNodeExpandMode.ServerSide,
//NW: This is overiden below.
NavigateUrl = child.Url, LongDesc = child.Description
};
// with the same expand mode as the node currently expanding
rtn.ExpandMode = e.Node.ExpandMode;
// add the new node to the node that is expanding
e.Node.Nodes.Add(rtn);
}
// now that the nodes are added, change the current node's expand mode to client-side
e.Node.ExpandMode = TreeNodeExpandMode.ClientSide;
// signal that the node is now expanded
e.Node.Expanded =
true;
}
NOTE:
// we are not using the following code
protected void NodeClickHandler(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
{
SiteMenu = (RadTreeView)sender;
LastSelectedNode = e.Node;
}
}
}
once again please help......we have a critical situation here that we are so close to fixing, and this is holding us back.
ps...tried attaching a zip!
regards
Shaun Pitt
Chisholm Institute - Australia