Where to add dynamic docks?

5 posts, 0 answers
  1. Jeff
    Jeff avatar
    100 posts
    Member since:
    Apr 2008

    Posted 08 Apr 2008 Link to this post

    I'm trying to build a page that uses dynamically-created Docks.  I've set up my RadDockLayout and RadDockZone as described in the examples.

    I'm creating a new Dock and adding it to the DockZone in a button event function, and that seems to be working.

    I'm repopulating the DockLayout from a List<DockState> in Page_Init(), and that seems to be working.  My dynamic Docks are surviving post-backs with contents intact.

    What I can't figure out is where to load Docks from the database.

    I have a RadTreeView on the same page, and what is supposed to be happening is that for whichever node in the tree is selected, that node's set of Docks are displayed in the DockZone.  Which means I need to clear the Docks that were added in Page_Load, empty the List<DockState> (I think, it may be that it'd be overwritten the next time OnSaveDockLayout is fired), and then I need to create Docks from the appropriate database records, and add them to the DockZone.

    I can't quite figure out  how to do either.  The first time I select a menu no Docks show up, and the second time I get an "multiple controls with the same ID "RodDock0" were found" error.


  2. Jeff
    Jeff avatar
    100 posts
    Member since:
    Apr 2008

    Posted 08 Apr 2008 Link to this post

    OK - I figured some of it out.

    The CreateRadDock() method I copied from the demo apps created a Dock with an ID derived from CurrentDockStates.Count - which does not increment just because you've called RadDockZOne.Controls.Add(dock);

    When I click on my "Add Dock" button, it adds one Dock, then CurrentDockStates is updated.  So the next time I click on my "Add Dock", it adds another Dock with a different ID.

    But when I loop, creating five or ten Docks in one post-back,
    CurrentDockStates.Count has the same value for all of them, so CreateRadDock() creates them all with the same ID.


    My attempts to clear out the Docks associated with the prior TreeNode still aren't working.  They're still there.

  3. Angela
    Angela avatar
    19 posts
    Member since:
    Mar 2008

    Posted 08 Apr 2008 Link to this post

    But when I loop, creating five or ten Docks in one post-back,
    CurrentDockStates.Count has the same value for all of them, so CreateRadDock() creates them all with the same ID.

    Hey Jeff,

    You want to use the for loop counter... CurrentDockStates.Count tells the TOTAL number of dockstates in the list.

    To set the ID

    for (int i=0; i<CurrentDockStates.Count; i++){
        dock.ID = i;
    }

    And if that isn't what you are looking for look through the intellisense to find the appropriate information..> I believe Tag and UniqueName are also available for recall..

    So it would be CurrentDockStates[i].Tag ect...

    Hope this helped...
  4. Jeff
    Jeff avatar
    100 posts
    Member since:
    Apr 2008

    Posted 09 Apr 2008 Link to this post

    That wasn't of much help.I'm not sure you quite grasped what I was saying.

    Suppose I had five Docks in the DockZone, prior to my postback, and I was setting the Docks' IDs from CurrentDockStates.Count.

    They'd be numbered 0 to 4.

    If I did a postback that added a new Dock, it'd set its ID to 5, since CurrentDockStates.Count was 5.  And after the postback, CurrentDockStates would be set to 6.

    But if I then did a postback that added two new Docks, I couldn't use CurrentDockStates.Count to name both of them, because during the postback
    CurrentDockStates.Count would have a constant value of 6, since adding the Docks to the DockZone doesn't update CurrentDockStates.

    Your comment regarding using the index from 0 to
    CurrentDockStates.Count-1 is appropriate, when I'm reconstructing the existing Docks in Page_Init(), but it's the last thing I want to do when I'm adding new Docks.  I want IDs that are different from any of the existing Docks, which is to say, I want ID's that are greater than CurrentDockStates.Count-1.

    Which is to say, that if I want to add two new Docks, I want to add them as
    CurrentDockStates.Count and CurrentDockStates.Count+1.
  5. Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 12 Apr 2008 Link to this post

    You can use Guid.NewGuid() instead counting the RadDocks, e.g.
    dock.UniqueName = Guid.NewGuid().ToString();
    dock.ID = string.Format("RadDock{0}", dock.UniqueName);

Back to Top