This is a migrated thread and some comments may be shown as answers.

Setting default values to treeview

5 Answers 67 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
OMER
Top achievements
Rank 1
OMER asked on 03 Mar 2014, 11:25 AM
Hi,
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:
{nodesItems: [{text: 'text1', id: 'id1', checked: 'true'}, ...]}
As I wrote above, the treeview appears, but how do I set the relevant nodes to be checked?

5 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 05 Mar 2014, 09:34 AM
Hello Omer,

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,
Alex Gyoshev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
OMER
Top achievements
Rank 1
answered on 06 Mar 2014, 09:11 AM
Hi,
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?
0
Alex Gyoshev
Telerik team
answered on 06 Mar 2014, 10:00 AM
Hello Omer,

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,
Alex Gyoshev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
OMER
Top achievements
Rank 1
answered on 06 Mar 2014, 04:55 PM
Hi,
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:
http://plnkr.co/edit/G5MR36?p=preview
What would be the best way to use this storage in order to recreate the treeview with the same state?
0
Alex Gyoshev
Telerik team
answered on 07 Mar 2014, 09:27 AM
Hello Omer,

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,
Alex Gyoshev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
TreeView
Asked by
OMER
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
OMER
Top achievements
Rank 1
Share this question
or