Current filter:
          You should refresh the page.
          Not Logged In

          Browser Refresh - Store/Restore Current Virtual Mode State?

          0
            • Hi,
              I use an ASPxTreeList control in virtual mode. Is it possible to store the current state of the control somehow, so that if a user navigates away from the page and later returns, the ASPxTreeList can be restored to it's previous state? When the user returns to the tree list page, I want the same nodes to be expanded and the focused node to be the same as they were when the user last visited the page.
              Many thanks,
              Ben

          0

          I suppose another way to do it would be for me to store details of the currently focused node. When the user revisits the page with the tree list on it, I would then find the node and call node.MakeVisible() and node.Focus() on it. I can't figure out how to do this with the tree list in virtual mode though. I have experimented with ASPxTreeList.RefreshVirtualTree() but without success.

          Any idea how to store/restore the current state of the TreeList, or to find and focus an individual virtual node when a user returns to the page?

          Thanks again.

          0

          Hi Ben,

          You should use the ASPxTreeList.SaveClientLayout / LoadClientLayout methods to preserve the TreeList's layout information and restore it when necessary. There is also the ClientLayout event which is triggered when you need to save / load the layout and passes all the necessary parameters. Please refer to the ASPxTreeList Members in this regard.

          Thanks,
          Plato

          0

          Thanks, that sounds like just what I need but I can't get it to work. I am using the ClientLayout event as per the documentation. I suspect this might have something to do with the fact that my tree list is contained within a Microsoft AJAX UpdatePanel (the tree list has EnableCallbacks set to false). I moved it outside the UpdatePanel and it worked fine (unfortunately I need the tree list to be within the UpdatePanel for other reasons).

          Can I get it to work in these circumstances?

          Thanks again,
          Ben S

          0

          Sorry, my mistake - I can't get it to work either inside or outside of an UpdatePanel. In the ClientLayout event, when e.LayoutMode is 'Save', e.LayoutData is always "AgAHAAcABwAHAAbw/w==" regardless of how many nodes I expand. Is this something to do with the tree list being in virtual mode? Can you help?

          0

          Hi Ben,

          You should change the ASPxTreeList.SettingsCookies property and mark which properties you would like to preserve. Also, if you set the ASPxTreeList.SettingsCookies.Enabled property value to true and specify the ASPxTreeList.SettingsCookies.CookiesID property, the ASPxTreeList will automatically preserve / load the required information to Cookies.

          Thanks,
          Plato

          0

          Thanks, that works but it doesn't seem to store the currently focused node. Is this possible? If not, I would like to suggest that a new property is added: SettingsCookies.StoreFocusedNode.

          0

          Hi Ben,

          You are right, the ASPxTreeList does not preserve the information about the focused node. I have registered a new suggestion to implement this feature in the future:

          Add an ability to store/restore the information about the FocusedNode

          For now, you may use the following code to save / load a focused node:

          	
          [C#]
          protected void treeList_ClientLayout(object sender, DevExpress.Web.ASPxClasses.ASPxClientLayoutArgs e) { ASPxTreeList treeList = (sender as ASPxTreeList); if(e.LayoutMode == DevExpress.Web.ASPxClasses.ClientLayoutMode.Saving) { if(treeList.FocusedNode != null) DevExpress.Web.ASPxClasses.Internal.RenderUtils.SetCookie(Request, Response, "focusedNode", treeList.FocusedNode.Key); } else { string keyValue = DevExpress.Web.ASPxClasses.Internal.RenderUtils.GetCookie(Request, "focusedNode"); TreeListNode node = treeList.FindNodeByKeyValue(keyValue); if(node != null) node.Focus(); } }

          Thanks,
          Plato

          0

          Thanks, but this doesn't work in virtual mode because the ClientLayout event is called before the VirtualModeCreateChildren and VirtualModeNodeCreating events, so the nodes don't yet exist. This doesn't seem like the right way round to me - is this something that can be changed in a future version, or are there good reasons for it that I am not aware of? Either way, is there another workaround I can use?
          Thanks again,
          Ben S

          0

          Hi Ben,

          I have attached a sample project showing how to preserve the information about a focused node using client code and restore it on the server. I hope it will be helpful to you. We are planning to add a similar code to the control itself.

          Thanks,
          Plato

          dxSample.zip
          You must  log in  or  register  to leave an answer