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

Set raddock height dynamically

1 Answer 79 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Ram
Top achievements
Rank 1
Ram asked on 21 Jan 2012, 12:29 PM
Hi all,
I'm using raddocks in my application.
Everythinng working fine.
I'm loading the custom controls which contain radgrid in raddock.
My problem is suppose if I have 10 records in radgrid I need to set the height of the docks to exactly for fitting 10 records.
I'm able to do it for the first time of creating dock.
Grid will get refresh for every 15 secs for example.
After refresh dock will be created from state,at the point of time also I'm also I'm trying to set the dock height ,but its not taking.
How to get rid of this problem, Please help me asap. Its urgent.
Here is my code.
private RadDock CreateRadDock(int i)
    {
        RadDock dock = new RadDock();
        dock.DockMode = DockMode.Docked;
        dock.EnableAnimation = true;
        dock.EnableRoundedCorners = true;
        dock.EnableEmbeddedSkins = true;
        dock.TitlebarContainer.BorderColor = System.Drawing.ColorTranslator.FromHtml("#548264");
        dock.TitlebarContainer.HorizontalAlign = HorizontalAlign.Left;
        dock.Resizable = true;
        dock.UniqueName = Guid.NewGuid().ToString();
        dock.ID = string.Format("RadDock{0}", dock.UniqueName);
  
        switch (i)
        {
            case 1:
                dock.ID = "1";
                dock.Tag = "1";
                break;
            case 2:
                dock.ID = "2";
                dock.Tag = "2";
                break;
            case 3:
                dock.ID = "3";
                dock.Tag = "3";
                break;
            case 4:
                dock.ID = "4";
                dock.Tag = "4";
                break;
            case 5:
                dock.ID = "5";
                dock.Tag = "5";
                break;
            case 6:
                dock.ID = "6";
                dock.Tag = "6";
                break;
        }
  
        dock.Width = Unit.Pixel(460);
          
        //assign client-side event handler
        dock.OnClientInitialize = "Dock_OnClientInitialize";
        DockCloseCommand closeCommand = new DockCloseCommand();
        closeCommand.AutoPostBack = true;
        DockExpandCollapseCommand expandCommand = new DockExpandCollapseCommand();
        dock.OnClientCommand = "ClientCommand";
        DockToggleCommand maximizeCommand = new DockToggleCommand();
        maximizeCommand.Name = "Maximize";
        maximizeCommand.Text = "Maximize";
        maximizeCommand.OnClientCommand = "Dock_OnMaximizeCommand";
        maximizeCommand.AlternateText = "Restore";
        maximizeCommand.CssClass = "max";
        maximizeCommand.AlternateCssClass = "min";
        dock.OnClientResizeEnd = "OnresizeEnd";
        dock.ContentContainer.Style.Add(HtmlTextWriterStyle.OverflowX, "hidden");        
        dock.Skin = "Outlook";
        setDockName();
        switch (dock.ID)
        {
            case "1":
                Control widget = LoadControl("~/DashBoard/Controls/AlarmSummaryCtrl.ascx");
                dock.Command += new DockCommandEventHandler(this.Dock1_Command);
                dock.ContentContainer.Controls.Add(widget);
                dock.Title = "Alarm Summary";
                dock.Height = Unit.Pixel(getAlrmDockHeight());
                break;
            case "2":
                widget = LoadControl("~/DashBoard/Controls/ActiveCallsCtrl.ascx");
                dock.Command += new DockCommandEventHandler(this.Dock2_Command);
                dock.Title = "Active Calls";
                dock.ContentContainer.Controls.Add(widget);
                dock.Height = Unit.Pixel(165);
                break;
            case "3":
                widget = LoadControl("~/DashBoard/Controls/PendingCallsCtrl.ascx");
                dock.Command += new DockCommandEventHandler(this.Dock3_Command);
                dock.Title = "Pending Calls";
                dock.ContentContainer.Controls.Add(widget);
                dock.Height = Unit.Pixel(165);
                break;
            case "4":
                widget = LoadControl("~/DashBoard/Controls/CallActivityForConsoleCtrl.ascx");
                dock.Command += new DockCommandEventHandler(this.Dock4_Command);
                dock.Title = consleDocTitle;
                dock.ContentContainer.Controls.Add(widget);
                dock.Height = Unit.Pixel(165);
                break;
            case "5":
                widget = LoadControl("~/DashBoard/Controls/CallActivityForDispatchrCtrl.ascx");
                dock.Command += new DockCommandEventHandler(this.Dock5_Command);
                dock.Title = disptrDocTitle;
                dock.ContentContainer.Controls.Add(widget);
                dock.Height = Unit.Pixel(165);
                break;
            case "6":
                widget = LoadControl("~/DashBoard/Controls/CallActivityForEndPntCtrl.ascx");
                dock.Command += new DockCommandEventHandler(this.Dock6_Command);
                dock.Title = endPntDocTitle;
                dock.ContentContainer.Controls.Add(widget);
                dock.Height = Unit.Pixel(165);
                break;
        }
  
        dock.OnClientDockPositionChanged = "dockPositionChanged";
        dock.Commands.Add(closeCommand);
        dock.Commands.Add(maximizeCommand);
        dock.Commands.Add(expandCommand);
        return dock;
    }
Creating dock from state:
private RadDock CreateRadDockFromState(DockState state)
   {
       RadDock dock = new RadDock();
       dock.EnableAnimation = true;
       dock.DockMode = DockMode.Docked;
       dock.EnableRoundedCorners = true;
       dock.EnableEmbeddedSkins = true;
       dock.TitlebarContainer.BorderColor = System.Drawing.ColorTranslator.FromHtml("#548264");
       dock.UniqueName = state.UniqueName;
       dock.ID = string.Format("RadDock{0}", state.UniqueName);        
       dock.ApplyState(state);
       dock.Resizable = true;
       dock.Skin = "Outlook";
       DockCloseCommand closeCommand = new DockCloseCommand();
       closeCommand.AutoPostBack = true;
       DockExpandCollapseCommand expandCommand = new DockExpandCollapseCommand();
       expandCommand.AutoPostBack = false;
       DockToggleCommand maximizeCommand = new DockToggleCommand();
       maximizeCommand.Name = "Maximize";
       maximizeCommand.Text = "Maximize";
       maximizeCommand.OnClientCommand = "Dock_OnMaximizeCommand";
       maximizeCommand.AlternateText = "Restore";
       maximizeCommand.CssClass = "max";
       maximizeCommand.AlternateCssClass = "min";
       //assign client-side event handler
       dock.OnClientInitialize = "Dock_OnClientInitialize";
       dock.OnClientCommand = "ClientCommand";
       dock.ContentContainer.Style.Add(HtmlTextWriterStyle.OverflowX, "hidden");
       dock.TitlebarContainer.HorizontalAlign = HorizontalAlign.Left;
       dock.OnClientResizeEnd="OnresizeEnd";        
       setDockName();
       dock.ApplyState(state);
       switch (state.Tag)
       {
           case "1":
               Control widget = LoadControl("Controls/AlarmSummaryCtrl.ascx");
               dock.Command += new DockCommandEventHandler(this.Dock1_Command);
               dock.ID = "1";
               dock.Title = "Alarm Summary";
               dock.ContentContainer.Controls.Add(widget);
               dock.Height = Unit.Pixel(getAlrmDockHeight());
               state.Height = Unit.Pixel(getAlrmDockHeight()); 
               break;
           case "2":
               widget = LoadControl("Controls/ActiveCallsCtrl.ascx");
               dock.Command += new DockCommandEventHandler(this.Dock2_Command);
               dock.ID = "2";
               dock.Title = "Active Calls";
               dock.ContentContainer.Controls.Add(widget);
               break;
           case "3":
               widget = LoadControl("Controls/PendingCallsCtrl.ascx");
               dock.Command += new DockCommandEventHandler(this.Dock3_Command);
               dock.ID = "3";
               dock.Title = "Pending Calls";              
               dock.ContentContainer.Controls.Add(widget);                                
               break;
           case "4":
               widget = LoadControl("Controls/CallActivityForConsoleCtrl.ascx");
               dock.Command += new DockCommandEventHandler(this.Dock4_Command);
               dock.ID = "4";
               dock.Title = consleDocTitle;                
               dock.ContentContainer.Controls.Add(widget);
               break;
           case "5":
               widget = LoadControl("Controls/CallActivityForDispatchrCtrl.ascx");
               dock.Command += new DockCommandEventHandler(this.Dock5_Command);
               dock.ID = "5";
               dock.Title = disptrDocTitle;
               dock.ContentContainer.Controls.Add(widget);
               break;
           case "6":
               widget = LoadControl("Controls/CallActivityForEndPntCtrl.ascx");
               dock.Command += new DockCommandEventHandler(this.Dock6_Command);
               dock.ID = "6";
               dock.Title = endPntDocTitle;
               dock.ContentContainer.Controls.Add(widget);
               break;
       }        
       dock.OnClientDockPositionChanged = "dockPositionChanged";
       dock.Commands.Add(closeCommand);
       dock.Commands.Add(maximizeCommand);
       dock.Commands.Add(expandCommand);        
       return dock;
   }
getAlrmDockHeight()  return height.
Pls help me asap.

1 Answer, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 25 Jan 2012, 03:28 PM
Hello Ram,

The new height that you are setting is not applied, because it is set on Page_Init, which occurs before the client state is applied and as a result the value of Height in the client state overrides the one you are specifying. I would suggest setting the Height of the RadDocks on Page_Load in order to ensure that the new value of the property is applied accordingly.

Regards,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Dock
Asked by
Ram
Top achievements
Rank 1
Answers by
Slav
Telerik team
Share this question
or