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

6 posts, 0 answers
  1. Jeffery
    Jeffery avatar
    18 posts
    Member since:
    Sep 2006

    Posted 28 Sep 2007 Link to this post

    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?
  2. Petya
    Admin
    Petya avatar
    869 posts

    Posted 03 Oct 2007 Link to this post

    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
  3. Jeffery
    Jeffery avatar
    18 posts
    Member since:
    Sep 2006

    Posted 03 Oct 2007 Link to this post

    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.
  4. Petya
    Admin
    Petya avatar
    869 posts

    Posted 04 Oct 2007 Link to this post

    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
  5. Jeffery
    Jeffery avatar
    18 posts
    Member since:
    Sep 2006

    Posted 04 Oct 2007 Link to this post

    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.
  6. Petya
    Admin
    Petya avatar
    869 posts

    Posted 08 Oct 2007 Link to this post

    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
Back to Top