Store the state in any way (cookies etc.) to restore it on a page load?

6 posts, 0 answers
  1. Stephan
    Stephan avatar
    4 posts
    Member since:
    Feb 2013

    Posted 26 Feb 2013 Link to this post

    Hello,

    after the page containing the tree view is refreshed, the state isn’t remembered so the tree view is collapsed totally. We have the requirement that the state is unchanged on a refresh or navigation operation on the browser.

    So our question: Is it possible to store the state in any way (cookies etc.) to restore it on a page load?

    Thanks in advance.

  2. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 28 Feb 2013 Link to this post

    Hello Stephan,

    I attached a sample project which shows one possible implementation to preserve the state. Check it and let me know if you have any questions.

    Regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Stephan
    Stephan avatar
    4 posts
    Member since:
    Feb 2013

    Posted 04 Mar 2013 Link to this post

    Hello,

    your example is not fully working yet. The treeview is displayed correctly and all expanded and collapsed states are handled the right way.
    But if we attach the collapsed and expand event we get an unexpected behavior:

    Example
    + Root
    + Foo
     - Foo 1
     - Foo 2
    - bar
    - blubb

    After the page reload we get the correct treeview, but if the users click on the node Foo (which is already expanded), the expanded-event is raised, instead of the collapsed-event. If the users click again the collapsed-event is raised like expected.

    The error appears in our projekt as well as in your sample project.

    Thanks in advance.
  5. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 06 Mar 2013 Link to this post

    Hello again Stephan,

    This is a known issue that has already been fixed in the latest internal builds and in the beta release, and the changes will be available in the next official release. The problem can be workaround with the current version by setting the "data-expanded" attribute on the nodes e.g.

    .ItemDataBound((item, customer) =>
        {
            item.Text = customer.ContactName;
            item.Id = customer.CustomerID;                         
            item.Expanded = ((string[])ViewData["ExpandedNodes"]).Contains(customer.CustomerID);
            if (item.Expanded)
            {
                item.HtmlAttributes["data-expanded"] = "true";
            }               
        })
    Regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Natraj
    Natraj avatar
    1 posts
    Member since:
    Aug 2013

    Posted 08 Apr 2014 Link to this post

    Hey Daniel,
    When I tried to execute this sample project (from PersistStateKendoTreeView.zip). I got following error. would you able to assists me on this?

    Compiler Error Message: CS1061: 'PersistStateKendoTreeView.Models.Customers' does not contain a definition for 'Orders' and no extension method 'Orders' accepting a first argument of type 'PersistStateKendoTreeView.Models.Customers' could be found (are you missing a using directive or an assembly reference?)

    Source Error:

    Line 21: }
    Line 22: })
    Line 23: .Children(customers => customers.Orders)
    Line 24: );
    Line 25:
  7. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 10 Apr 2014 Link to this post

    Hello,

    Have you made any modifications to the project. It is running as expected on my side. The exception messages suggests that the "Orders" navigational property is removed from the Customer class.

    Regards,
    Daniel
    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.

     
Back to Top
UI for ASP.NET MVC is VS 2017 Ready