34 Answers, 1 is accepted
How exactly did you use the Session variable?
You can store the state of the treeview in the session like this:
Session["myTreeView"] = RadTreeView1.GetXml(); |
and later restore the treeview state from that session variable:
string treeViewState = (string)Session["treeViewState"]; |
RadTreeView1.LoadXmlString(treeViewState); |
I hope this will get you started.
Sincerely yours,
Veskoni
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I guess you need to use a navigation control like LinkButton that will perform a postback on click and navigate after that:
asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Click Here to navigate</asp:LinkButton> |
protected void LinkButton1_Click(object sender, EventArgs e) |
{ |
//save the session. Alternatively you can save the XML string in a temporary table in the DB |
Session["myTreeView"] = RadTreeView1.GetXml(); |
//navigate |
Response.Redirect("..."); |
} |
I hope this helps.
Greetings,
Veskoni
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
<radT:RadTreeView id="RadTreeView1" BeforeClientClick="BeforeClickHandler" runat="server" NodeCssClassSelect=" "
NodeCssClassOver=" " NodeCssClassEdit=" " NodeCssClassDisable=" " NodeCssClass=" " Skin="TSA"></radT:RadTreeView>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" OnAjaxRequest="RadAjaxManager1_AjaxRequest" runat="server">
</telerik:RadAjaxManager>
<telerik:AjaxSetting_AjaxControlID="RADAJAXMANAGER1"></TELERIK:AJAXSETTING>
<script language="JavaScript" type="text/javascript">
function BeforeClickHandler()
{
<!--
RadAjaxManager1.AjaxRequest();
return false;
-->
}
</script>
But now in 2.0 it hangs with this error upon clicking a node to be redirected Microsoft JScript runtime error: Object doesn't support this property or method
and it is referring to the RadAjaxManager1.AjaxRequest(); call. Any ideas?
So, you are using the "classic" RadTreeView and the new RadAjaxManager? Why don't you use the new RadTreeView as well?
You need to call ajaxRequest() instead of AjaxRequest() method.
All the best,
Veskoni
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
yet in my web.config file this is what i have
<httpHandlers>
<remove path="*.asmx" verb="*"/>
<add path="*.asmx" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
<add path="*_AppService.axd" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
<add path="ScriptResource.axd" verb="GET,HEAD" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
<add path="*.asbx" verb="GET,HEAD,POST" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
<add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI, Version=2008.2.723.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4" validate="false"/>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
do you see anything wrong here?
The GetXml is good and generating the xml without any problem but what if i wanted to short the nodes of XML pls help regarding this.
U can better understand my requirement by going through this.
http://www.telerik.com/community/forums/aspnet-ajax/treeview/how-to-short-nodes-in-redtreenode-after-pasting-a-node.aspx
Thanks
Rupesh
Please check the forum thread - we've already answered to your question there.
Regards,
Yana
the Telerik team
I am trying to implement the samething in Silverlight, is it possible RadTreeView.
Thanks,
Kartheek
Could you please post your question in the Silverlight forum here? Thanks
Best wishes,
Yana
the Telerik team
Please find the thread.
http://www.telerik.com/community/forums/silverlight/treeview/save-the-treeview-state.aspx
Thanks,
Kartheek
Please check the SilverLight forum again. Thanks
Greetings,
Yana
the Telerik team
your approach is working well but it is costlier
one coz we have 7 trees in a single page and those are divided by
tabs. So how to do the same functionality without taking whole XML content into
a session object.
Thanks
Rama.
Stored expanded nodes in a Dictionary object and have to expand the parent and child nodes though page refresh happens.
Below is the code ... Child nodes are expanding in LoadOnDemand for the first time.
Private Shared dictOriginTree As New Dictionary(Of String, Boolean)
Protected Sub rtvOriginTree_NodeExpand(sender As Object, e As RadTreeNodeEventArgs)
If Not dictOriginTree.ContainsKey(e.Node.UniqueID) Then
dictOriginTree.Add(e.Node.UniqueID, e.Node.Expanded)
End If
End Sub
Protected Sub ramMasterDocumentsAjaxManager_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs)
Dim node As RadTreeNode
For Each node In rtvOriginTree.GetAllNodes()
If dictOriginTree.ContainsKey(node.UniqueID) Then
node.ExpandParentNodes()
node.ExpandChildNodes()
node.Expanded = dictOriginTree.Item(node.UniqueID.ToString())
node.ExpandMode = TreeNodeExpandMode.ServerSide
End If
Next
End Sub
You could try to use RadTreeView with RadPersistenceFramework. It allows you to preserve Selected, Checked and expanded nodes. Here is the online demo:
http://demos.telerik.com/aspnet-ajax/treeview/examples/applicationscenarios/persisting-treeview-settings/defaultcs.aspx?product=persistenceframework
Regards,
Hristo Valyavicharski
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Thank you very much for your reply.I gone through the Demo and saw the code but in the code Session object being used. My questions are
1) Is it possible without using Session
2) In my case i have total of 7 RadTreeView controls in a single page. So i should use 7 different Session objects ? Absolutely it will hit the performance.
Protected Sub SaveButton_Click(sender As Object, e As EventArgs)
Session("CustomPersistenceSettingsKey") = Me.Session.SessionID
Dim fileId As String = Session("CustomPersistenceSettingsKey").ToString()
LoadButton.Enabled = True
RadPersistenceManager1.StorageProviderKey = fileId
RadPersistenceManager1.SaveState()
End Sub
I have replied to your question here:
http://www.telerik.com/forums/radtreeview-save-expanded-state-without-session-object#JgMUUf6GEk-Uw20sHj-TyA
Please do not write in different threads for the same question.
There is no need to have 7 different session objects. We are using the session, because in the demo we need to identify the anonymous users who browse the page.
Regards,
Hristo Valyavicharski
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
I saw the demo posted before using the persistence framework but i can't seem to be able to make it work.
I'm in a situation where I use a radtreeview as links sidebar in my webform, it's actually located in a master page.
The treeview is populated with RadTreeView.LoadContentFile(); method loading it from an xml file.
In which events should I put the load and save sessions?
Thanks, regards
The LoadState(); method should be called, when page is loaded, but after the tree is populated with data.
The SaveSate() method needs to be called, when you expand any node or when node is selected. Suitable events are NodeExpand and NodeClick.
Regards,
Hristo Valyavicharski
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
My issue is very similar to what is discussed in this post. However, it has some peculiarities.I have to maintain an old application which uses RadTreeView. This RadTreeView is defined as a menu in a master page and repopulated in Page_Init event handler for the master page. I need to save the current expansion state of the tree and preserve it when the tree is recreated.
What makes my task difficult is that I do not have (or at least I do not know) an event when to catch and preserve the expansion status of the tree. When tree is collapsed and/or expanded in the browser, I do not get the post back to save the status. I cannot move the population of the tree from the master page Page_Init to Page_Load handler because it is used in Page_Load event of the content pages, which is triggered before Page_Load of the master page.
So, here is my question: how without changing user's experience (by introducing some bogus link buttons) capture RadTreeView expansion status?
The PersistenceFramework is a server control and to use it you will have to make a full post back or at least an ajax call. It is possible to store the expanded and selected nodes in a cookie without making any postbacks. You will have to handle the OnClientNodeExpanded and OnClientNodeSelected events. In these events save the data you need in a cookie. This way you will always have the latest changes.
Finally after you have selected and expanded nodes you will have to restore them somehow. This can be done in the pageLoad event.
function
pageLoad() {
}
I hope this helps.
Regards,
Hristo Valyavicharski
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Is that possible to save state of RadTreeView using "RadPersistenceManager " when expand a node on-demand base ?
I applied for one of the tree which is on-demand base using RadPersistenceManager and its not working.
Please confirm.
The RadMersistenceManager applies state only to existing nodes. In case that the nodes are not loaded it is not possible to apply the saved state.
Regards,
Peter Filipov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
I would like to know is there any other ways to do it, not only using RadPersistenceManager.
Thanks
Ramakrishna.
Our control does not support such API and it is not possible to do it out of the box. You will to implement it on your own.
Regards,
Peter Filipov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Thank you very much for your suggestion. It was working fine... until I got a couple of menu options with the same text.
Unfortunately menu nodes do not have unique IDs so I was identifying the nodes by text. When there are more than one node with the same text, preserving the menu state becomes impossible.
Would you have any suggestion on how to rectify this situation?
I would suggest that you try the following approach:
- Enable the menu selection:
<
telerik:RadMenu
runat
=
"server"
EnableSelection
=
"true"
ID
=
"RadMenu1"
>
- In the cookie store the item's text or value.
- Use menu client api to find and select the item you want:
function
restoreSelectedItem() {
//...
var
menu = $find(
'RadMenu1'
);
var
item = menu.findItemByText(
"Home"
);
if
(item !=
null
) {
item.select();
}
}
I hope this helps.
Regards,
Hristo Valyavicharski
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
I have project use radtreeview to checkbox node and then save in SQL server as database but not working.
Please help me
see attachment.
Hi
I have project to select from radtreeview and save in database, but the save button not working to save in sql server
I have role table, operation table and roleoperation table after check box from treeview and click save button in roleoperation table
but save button can not save from treeview.
see some image.
I have project to select from radtreeview and save in database, but the save button not working to save in sql server
I have role table, operation table and roleoperation table after check box from treeview and click save button in roleoperation table
but save button can not save from treeview.
see some image.
Please open new support ticket and attach sample project.
Thanks.
Regards,
Hristo Valyavicharski
Telerik