Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
gTree -> Localstorage
posted

Hi,

How can I use gTree with localStorage to save the opening of the hierarchy ?

Thanks pour for you help.

Damien

Parents
  • 2895
    posted

    Hello Damien,

    Thank you for contacting us.

    If I understand you correctly, you would like to save the expanded node on expanding? To achieve such a functionality, you can use the NodeExpanded event and in the handler you can save the particular node like this:

    nodeExpanded: function(evt, ui) {

                if (typeof(Storage) !== "undefined") {

                  // Code for localStorage.

                  var node = ui.node;

                  //save

                  localStorage.setItem("key", JSON.stringify(node));

                  //retrieve

                  var savedNode = localStorage.getItem("key");

                    savedNode = JSON.parse(savedNode);

                    //saved node

                    $("#localStore").html(savedNode.data.RegionName);

                  } else {

                    // Sorry! No Web Storage support..

                    alert("No localStorage support!");

                  }

     

                }

    Here is a corresponding sample. Please take a look at it and let me know if you have further questions.

    http://jsfiddle.net/h1xeu8th/14/

    Best Regards,
    Marina Stoyanova,
    Software Developer,
    Infragistics, Inc.

Reply Children