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

Removing a Dock programmatically

2 Answers 92 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Rob Linxweiler
Top achievements
Rank 2
Rob Linxweiler asked on 09 Nov 2009, 09:56 PM
Hello,

I've built a "portal" interface, combining dynamic TabStrip and RadDockLayout/Zone/Dock controls, fed from a database.

When the user clicks on a different tab, I want to show a different set of docks.  On the postback, though, the docks from the soon-to-be-previous tab are still in viewstate and get reattached to their Zones.  I added a method to clear them:

    ''' <summary> 
    ''' Clear all docks from a given raddocklayout 
    ''' </summary> 
    ''' <param name="rdLayout">given raddocklayout</param> 
    ''' <remarks></remarks> 
    Public Sub ClearAllDocks(ByVal rdLayout As RadDockLayout) 
        Dim rdZones As ReadOnlyCollection(Of RadDockZone) = rdLayout.RegisteredZones() 
        For Each rdZone As RadDockZone In rdZones 
            rdZone.Docks.Clear() 
            'For Each rdDock As RadDock In rdZone.Docks() 
            '    rdDock.Closed = True 
            'Next 
        Next 
    End Sub 

The .Clear() method isn't working.  It just plain doesn't clear the Zone.  The Docks are still there, before and after the .Clear() call.

I changed to the (commented out) .Closed = True option, but that seems slow and klunky to me. 

a) is there a reason that .Clear() wouldn't work?  I do realize I'm using a readonly collection to access them, but RegisteredZones only returns readonly. 

b) is there a better way of clearing all the Docks in a Layout? 

Thanks!

2 Answers, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 12 Nov 2009, 02:01 PM
Hi Rob,

Regarding your questions:

1. The Clear() method is not working, because the Collection of RadDocks is, as you said, read-only and cannot be modified.

2. There is no other way to clear the docks in the layout. To improve the performance, my recommendation is, when you change the tab, to [re]create the set of docks that are associated with the current tab. This way only the docks that can be seen from a certain tab, will be present on the page and the others will not be there.

Regards,
Pero
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Accepted
skysailor
Top achievements
Rank 1
answered on 19 Nov 2009, 05:03 AM
Hi,

Try :-
rdZone.Docks.Clear();
rdZone.Controls.Clear();

That worked for me!

Clayton
Tags
Dock
Asked by
Rob Linxweiler
Top achievements
Rank 2
Answers by
Pero
Telerik team
skysailor
Top achievements
Rank 1
Share this question
or