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

Where to add dynamic docks?

4 Answers 121 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 08 Apr 2008, 07:16 PM
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.


4 Answers, 1 is accepted

Sort by
0
Jeff
Top achievements
Rank 1
answered on 08 Apr 2008, 07:39 PM
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.

0
Angela
Top achievements
Rank 1
answered on 09 Apr 2008, 01:31 AM
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...
0
Jeff
Top achievements
Rank 1
answered on 09 Apr 2008, 02:07 PM
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.
0
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 12 Apr 2008, 09:58 AM
You can use Guid.NewGuid() instead counting the RadDocks, e.g.
dock.UniqueName = Guid.NewGuid().ToString();
dock.ID = string.Format("RadDock{0}", dock.UniqueName);

Tags
Dock
Asked by
Jeff
Top achievements
Rank 1
Answers by
Jeff
Top achievements
Rank 1
Angela
Top achievements
Rank 1
Obi-Wan Kenobi
Top achievements
Rank 1
Share this question
or