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

How to save / load DockLayout (not from session object)

5 Answers 210 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Jeffery
Top achievements
Rank 1
Jeffery asked on 28 Sep 2007, 07:03 PM
I have played with Docking control for few days.  I was able to save docking layout after postback using the "My Portal"sample as base.  However, I do not want to use session object to store DockStates, since it may be timed out.  Is there anyway that I can store it in ViewState (yes, I know that LoadDockLayout evetn happened before LoadViewState.)?  I guess that I can save it to database or server cache, but is there any easier solution?

5 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 03 Oct 2007, 09:24 AM
Hi Jeffery,

You could use ViewState, however it is meant to save information about the page whereas Session stores information per user across pages which is meaningful in an example as MyPortal. Furthermore, the state of the docks is persisted in ViewState by default. So, if you open a normal page and move, collapse/expand docks and make a postback, their state is preserved. However, if you go to another page and then come back to your page the docks will be in their initial state, not in the one you left them. Using Session, XML file, database are better options if you want to preserve the state across page redirects.

Sincerely yours,
Petya
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jeffery
Top achievements
Rank 1
answered on 03 Oct 2007, 05:15 PM
Now I am a little bit confused.  I have based my code from your "My Portal" sample.  In the sample, layout information are stored into Session variable, so we can retain the layout after postback.  Your documentation also mentions re-adding dock controls in Page_Init and using SaveDockLayout / LoadDockLayout event handlers to deal with docks created / modified from user actions.

Here is what I want to accomplish: in my page users can add and rearrange sections (each section is a dock control).  I want user to make all the changes using client side and/or ajax.  In the end, they can save the result to DB.  If layout can be preserved in ViewState which I thought it should be at the beginning, that will be great: I do not need all the messy code in page_Init, SaveDockLayout and LoadDockLayout at all.  However, I could not make it work.  Do you have a sample project that you can share?

Thanks.
0
Petya
Telerik team
answered on 04 Oct 2007, 12:33 PM
Hello Jeffery,

Before we continue the discussion, I would like to know a bit more about your particular scenario. Is it exactly the same as our MyPortal example, e.g. that on every move, collapse, expand, close, etc. of a dock the state is preserved? Or is it that your users can add docks, rearrange them and only when they press a Save button, the docks' state is saved in the DataBase? In both cases you have dynamic docks and you will need to re/create docks in PageInit.

Best wishes,
Petya
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jeffery
Top achievements
Rank 1
answered on 04 Oct 2007, 01:29 PM
Sorry I did not make it clear at the first place.  What I want to do is the second scenario as you stated.  In this case,

1) Should I still recreate docks in Page_Init.  The answer is yes.

2) Should I still need session, server cache or else to store docks' states on each user move?  Your documentation and examples suggest the answer is yes.  Is this right?

3) Your examples uses Session, Cookies and DB for 2).  I'd like to use ViewState for this, unfortunately I could not do so due to event timing issue: RadDockLayout.LoadDockLayout happened before ViewState is loaded.  I am wondering if this is very intuitive.  Can this is done by control ViewState automatically?

Thanks.
0
Petya
Telerik team
answered on 08 Oct 2007, 03:30 PM
Hello Jeffery,

Apologies for the delayed answer.

1) You need to recreate the docks on PageInit from DB

2) Upon move or clicking a dock's command do not perform anything, i.e. your dock should have AutoPostBack=False and CommandsAutoPostBack = False

3) In PageInit you load the state from DB. Upon Save button click you save it in DB. Handle LoadDockLayout and SaveDockLayout because when adding a dock you still go to the server.

Sincerely yours,
Petya
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Dock
Asked by
Jeffery
Top achievements
Rank 1
Answers by
Petya
Telerik team
Jeffery
Top achievements
Rank 1
Share this question
or