tags:

views:

403

answers:

2

Hi there,

I have a treeview (using an unordered list and JQuerys treeview) in my MVC app and i am wondering the best way to keep the nodes open and close state persisted on postback?

A: 

Throw the list into a cookie would be my best idea (then pull it out if it is there, otherwise show the default tree). http://www.quirksmode.org/js/cookies.html

You could also send it to the database and retrieve it, but that might be a little slower...

//edit: This might help:

http://www.shopdev.co.uk/blog/cookies-with-jquery-designing-collapsible-layouts/

SeanJA
+3  A: 

The treeview comes with an inbuilt persistence mechanism.

   $(".selector").treeview({
       persist: "cookie"
    })

See here

redsquare
haha easy. Thanks mate
Ah... didn't realise that treeview was a plugin
SeanJA