Hi,
How can I use gTree with localStorage to save the opening of the hierarchy ?
Thanks pour for you help.
Damien
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.
Thanks Marina pour your help.
rather, I wish that unfolded nodes is kept in the browser refresh, I hope I express myself clearly.
Thanks you.
Hello,
I have updated the sample to correspond to your requirements. The main idea is that you need to store in the localStorage something that identifies the node. And then on reload/refresh of the page to use the expand method from our API and expand the saved nodes. Please try my sample and if you have questions let me know.
Thanks a lot Marina, This sample will help me a lot
Best Regards,