I have the following setup:
I'm using angularjs.
I have a treeview in one page, and I keep the stats to this page in a session variable (a "Service", across all my pages).
Everything works fine, and the treeview loads fine.
The only problem is - how do I keep the selected nodes across all pages, and show them when relevant (i.e. when I get back to the page with the treeview)?
I can keep the data in the service, so it is availablein the following format:
As I wrote above, the treeview appears, but how do I set the relevant nodes to be checked?
5 Answers, 1 is accepted
From the provided information, it appears that the checked field needs to be stored as a boolean. If that doesn't resolve the problem, please provide more details on how the problem occurs.Regards,
The structure I provided was just how I am keeping the data.
I would like to know if there's a good way to keep the treeview data across the sessions?
Regarding user experience, I guess I could use templates (like here: http://plnkr.co/edit/G5MR36?p=preview) and keep the data bound to the data array (e.g. the status item in the object) and this way, the user will always see the correct checkboxes checked.
The problem arises with the datasource itself, which will be cleared regardless. What I'm doing now is keeping an external variable that keeps track over the states of the tree (e.g. each checkbox activates a certain function, and all this function needs to know is weather the checkbox is true/false).
Is there a better way of doing this? A more "kendo" way?
The TreeView and the DataSource do not provide a way of storing the checked state between sessions. Since the dataSource itself is changed, possible solutions are to sync it with a server that holds the data (remote service), or with some offline storage (for an example that uses Mozilla LocalForage, see this offline datasource).Regards,
Thanks for confirming my suspicion regarding storage.
I have the data stored.
I'm currently using templates (the checkboxes get a "checked" attribute according to the "status") as I've done here:
What would be the best way to use this storage in order to recreate the treeview with the same state?
Since there is no feature that allows persistence of the TreeView state, developing it falls outside the standard support package. If you need consulting on how to implement this, contact the Telerik Services.Regards,