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

dynamic raddock problem

6 Answers 199 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Jains
Top achievements
Rank 1
Jains asked on 18 Jan 2010, 09:17 PM
Hi,

I am creating a dynamic raddock  then storing into database.  When I do a postback  I am  not retreiving and displaying the raddock in saved BUT on a 2nd postback it is working ok.  The bigger problem is that if I run again it should pull from database and display raddock in zones that was last saved loads the raddock in the original position.   It seems that I am missing something in _init.  
I have reviewed on-line example and forums but  have not found anything to solve my problem.  

 

<table>

 

 

 

<tr><td><asp:button runat="server" id="Button1" text="save dashboard" />

 

 

 

<br/><br/></td></tr>

 

 

 

 

<telerik:raddocklayout runat="server" enableviewstate="false" id="RadDockLayout1" onloaddocklayout="RadDockLayout1_LoadDockLayout" Skin="Web20"

 

 

 

onsavedocklayout="RadDockLayout1_SaveDockLayout" storelayoutinviewstate="false" >

 

 

 

<tr>

 

 

 

 

<td valign="top">

 

 

 

 

 

 

 

<telerik:raddockzone runat="server" id="RadDockZone1" width="402px" min-height="200px">

 

 

 

 

</telerik:raddockzone>

 

 

 

</td>

 

 

 

<td valign="top">

 

 

 

<telerik:raddockzone runat="server" id="RadDockZone2" width="402px" min-height="200px">

 

 

 

</telerik:raddockzone>

 

 

 

</td></tr>

 

 

 

<tr><td colspan="2"><telerik:raddockzone runat="server" id="RadDockZone3" Width="820px" MinHeight="200px" >

 

 

 

 

</telerik:raddockzone></td></tr>

 

 

 

</table>

 

 

 

 

</telerik:raddocklayout>

 

 

 



 

private void Page_Load(object sender, System.EventArgs e)

 

{

 

}

 

 

 

private List<DockState> CurrentDockStates

 

{

 

 

get

 

 

{

 

//Get saved state string from the database - set it to dockState variable for example

 

 

 

string dockStatesFromDB = "";

 

 

 

string loginID = "xxx";

 

 

 

string loginPassword = "xxx";

 

 

 

using (XcendaDC1DataContext context = new XcendaDC1DataContext())

 

{

 

 

var users = from u in context.tbUsers

 

 

 

where (u.U_userLogin.Contains(loginID) && u.U_userPassword.Contains(loginPassword))

 

 

 

select u;

 

 

 

var x = users.FirstOrDefault();

 

 

 

if (x != null)

 

{

dockStatesFromDB = x.U_dockState;

 

}

}

 

 

List<DockState> _currentDockStates = new List<DockState>();

 

 

 

string[] stringStates = dockStatesFromDB.Split('|');

 

 

 

foreach (string stringState in stringStates)

 

{

 

 

if (stringState.Trim() != string.Empty)

 

{

_currentDockStates.Add(

 

DockState.Deserialize(stringState));

 

}

}

 

 

return _currentDockStates;

 

}

}

 

 

 

 

protected void Page_Init(object sender, EventArgs e)

 

{

 

 

int docksCount = CurrentDockStates.Count;

 

 

 

// raddock1

 

 

 

RadDock raddock1 = new RadDock();

 

raddock1.ID =

 

string.Format("RadDock{0}", docksCount);

 

raddock1.Title =

 

"Products";

 

 

 

// raddock1.Text = string.Format("Added at {0}", DateTime.Now);

 

 

raddock1.UniqueName =

Guid.NewGuid().ToString();

 

raddock1.Width =

 

Unit.Pixel(300);

 

raddock1.Skin =

 

"Web20";

 

 

 

RadGrid gv = new RadGrid();

 

 

 

ArrayList arrListProducts = new ArrayList();

 

arrListProducts.Add(

 

"product 1");

 

arrListProducts.Add(

 

"product 2");

 

arrListProducts.Add(

 

"product 3");

 

arrListProducts.Add(

 

"product 4");

 

arrListProducts.Add(

 

"product 5");

 

arrListProducts.Add(

 

"product 6");

 

arrListProducts.Add(

 

"product 7");

 

gv.DataSource = arrListProducts;

gv.DataBind();

raddock1.ContentContainer.Controls.Add(gv);

raddock1.Commands.Add(

 

new DockCloseCommand());

 

raddock1.Commands.Add(

 

new DockExpandCollapseCommand());

 

 

RadDockZone1.Controls.Add(raddock1);

}

 

 

 

 

 

 

 

protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e)

 

{

 

 

//Populate the event args with the state information. The RadDockLayout control

 

 

 

// will automatically move the docks according that information.

 

 

 

foreach (DockState state in CurrentDockStates)

 

{

e.Positions[state.UniqueName] = state.DockZoneID;

e.Indices[state.UniqueName] = state.Index;

}

}

 

 

 

 

protected void RadDockLayout1_SaveDockLayout(object sender, DockLayoutEventArgs e)

 

{

 

 

List<DockState> stateList = RadDockLayout1.GetRegisteredDocksState();

 

 

 

StringBuilder serializedList = new StringBuilder();

 

 

 

int i = 0;

 

 

 

while (i < stateList.Count)

 

{

serializedList.Append(stateList[i].ToString());

serializedList.Append(

 

"|");

 

i++;

}

 

 

string dockState = serializedList.ToString();

 

 

 

if (dockState.Trim() != String.Empty)

 

{

 

 

string loginID = "myID";

 

 

 

string loginPassword = "myPassword";

 

 

 

using (XcendaDC1DataContext context = new XcendaDC1DataContext())

 

{

 

 

var users = from u in context.tbUsers

 

 

 

where (u.U_userLogin.Contains(loginID) && u.U_userPassword.Contains(loginPassword))

 

 

 

select u;

 

 

 

var x = users.FirstOrDefault();

 

 

 

if (x != null)

 

{

x.U_dockState = dockState;

context.SubmitChanges();

}

}

}

}

 

6 Answers, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 19 Jan 2010, 08:48 AM
Hello Jains,

I have carefully examined the source code and noticed the following issues:

  • On every postback (or AJAX  call) you are assigning new value to the UniqueName property instead of using the one from the DockState. This causes the docks to be not positioned in the right zone and the correct index.
  • You are never calling the dock.ApplyState(DockState) method, so that the existing state is applied to the respective dock. Please make sure that the state is applied.

Please test the following projects from our Code Library:

Best wishes,
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
Jains
Top achievements
Rank 1
answered on 21 Jan 2010, 09:08 PM

Pero,

Thank you for your quick reply!!!  You reply made perfect sense.  I am now getting  a JavaScript error when moving a raddock

 

Microsoft JScript runtime error: 'currentLoadingPanel' is null or not an object

 

If I comment out the script it works fine with the exception of the 1st time a raddock is moved it goes back to the original position.

After that the raddock moves,saves and load correctly.

 

Your help in resolving this is appreciated as management is waiting for an solution.

 

Thanks

Rose

0
Pero
Telerik team
answered on 26 Jan 2010, 12:47 PM
Hello Rose,

I suppose you are referring to the client-script from one of the samples, the one that shows and hides the AJAX loading panel. The problem might be caused by the fact that you have placed the content in a WebUserControl or MasterPage-ContentPlaceHolder. This causes the controls' client IDs to be different than the server ones. To overcome the problem use the following (slightly modified) script:

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
 
    <script type="text/javascript">
        var currentLoadingPanel = null;
        var currentUpdatedControl = null;
        function RequestStart(sender, args)
        {
            currentLoadingPanel = $find("<%=LoadingPanel1.ClientID %>");
            currentUpdatedControl = "TableLayout";
            currentLoadingPanel.show(currentUpdatedControl);
        }
        function ResponseEnd()
        {
            //hide the loading panel and clean up the global variables
            if (currentLoadingPanel != null)
                currentLoadingPanel.hide(currentUpdatedControl);
            currentUpdatedControl = null;
            currentLoadingPanel = null;
        }           
    </script>
 
</telerik:RadCodeBlock>

In case this does not help, please provide more information about the problem (like a sample project that can be run locally).

Greetings,
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
Jains
Top achievements
Rank 1
answered on 26 Jan 2010, 08:57 PM

Pero

 

Thanks the modified script did the trick!


R

0
Ram
Top achievements
Rank 1
answered on 09 Sep 2011, 05:46 AM
Hi
In my application I'm using raddocks.
Im having total  6 dockzones and 6 docks. Every I'm loading the usercontrols(with radgrid) in every dock.
After loading the docks. If I close the first dock then second dock will move to fisrt and third to second and so on....
But when I closed first one its ok, but if I closed the second I'm getting the error like as below

"Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index."

And also the page is loading two times and every usercontrol called two times.
cloud you please help me out.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DashBoard.aspx.cs" Inherits="DashBoard_DashBoard" EnableEventValidation="false"%>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
  
<!DOCTYPE HTML />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
    <link href="../css/main.css" type="text/css" rel="stylesheet" />
    <link href="../css/jquery-ui.css" type="text/css" rel="stylesheet" />
    <script src="../Scripts/jquery.min.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-ui.min.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.ui.core.min.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-ui-1.8.5.custom.min.js" type="text/javascript"></script>
    <title>Dashboard</title>
    <style type="text/css">
        .style1
        {
            width: 119%;
            height: 324px;
        }
        .style3
        {
            width: 265px;
            height: 284px;
        }
    </style>
    <%-- Css for maximize and minimize button--%>
    <style type="text/css">
        .max
        {
            /*change the url of the image */
            width: 20px !important;
            background: url('../images/maximize.gif') no-repeat !important;
        }
        .min
        {
            /*change the url of the image */
            width: 20px !important;
            background: url('../images/minimize.jpg') no-repeat !important;
        }
        .style5
        {
            width: 265px;
            height: 182px;
        }
        .style6
        {
            width: 265px;
            height: 181px;
        }
    </style>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function dockInitialize(obj, args) {
                OverrideClose();
            }
            // When a dock is closed, its DockZoneId is stored into the hidden field
            function ClientCommand(sender, args)
             {
                 if (args.Command.get_name() == "Close") 
                {
                    var hiddenField = $get("<%= closedDockZoneId.ClientID %>");
                    hiddenField.value = sender.get_dockZoneID();
                }
            }
            //When the content area of a dock is clicked, page navigation to the desired location must take place
            function Dock_OnClientInitialize(dock, args) {
                var dockElem = dock.get_contentContainer();  //get reference to the dock's wrapper element
                $addHandler(dockElem, "click", function () {
                    switch (dock.get_title())//assign different pages to the docks according their title
                    {
                        case "Alarm Summary":
                            window.location = "AlarmSummary.aspx";
                            break;
                        case "Active Calls":
                            window.location = "ActiveCalls.aspx";
                            break;
                        case "Pending Calls":
                            window.location = "PendingCalls.aspx";
                            break;
                        case "Call Activity for Active Consoles":
                            window.location = "CallActivityForConole.aspx";
                            break;
                        case "Call Activity for Active Dispatchers":
                            window.location = "CallActivityForDispatchr.aspx";
                            break;
                        case "Call Activity for Active Endpoints":
                            window.location = "CallActivityForEndPnt.aspx";
                            break;
                    }
                }, false);
            }
  
            function Dock_resize(dock, args) {
                args.Command.set_state(args.Command.get_state() == 1 ? 2 : 1);
            }
  
            function noError() {
                return true;
            }
            window.onerror = noError;
            //Function for providng maximize and minimize features for the docks
            var dockZoneID = "";
            var dockInitialSize = {};
            function Dock_OnMaximizeCommand(dock, args) {
                if (window.innerHeight != undefined)
                    var viewportSize = { 'width': window.innerWidth + "px", 'height': window.innerHeight + "px" };
                //var viewportSize = { 'width': 750, 'height': 550 };
                else
                    var viewportSize = { 'width': document.documentElement.clientWidth + "px", 'height': document.documentElement.clientHeight + "px" };
                //var viewportSize = { 'width': 750, 'height': 550 };
                if (args.Command.get_state() == 1) {
                    //primary state
                    dockZoneID = dock.get_dockZoneID(); //store the dockZone where the dock was docked
                    dock.undock();
                    //set absolute position manually to workaround a bug in the undock() method
                    dock.get_element().style.position = "absolute";
                    //position the dock according to the layout wrapper
                    dock.set_top("0px");
                    dock.set_left("0px");
                    //store original dock size
                    dockInitialSize.width = dock.get_element().clientWidth;
                    dockInitialSize.height = dock.get_element().clientHeight;
                    //maximize the dock
                    dock.set_width(viewportSize.width);
                    dock.set_height(viewportSize.height);
                    //set the state of the command
                    args.Command.set_state(args.Command.get_state() == 1 ? 2 : 1);
                    command.set_state(1);
                }
                else {
                    //alternate state
                    //restore original dock size
                    dock.set_width(dockInitialSize.width);
                    dock.set_height(dockInitialSize.height);
                    if (dockZoneID)
                        $find(dockZoneID).dock(dock); //dock the dock to its zone
                    //set the state of the command
                    args.Command.set_state(args.Command.get_state() == 1 ? 2 : 1);
                    command.set_state(2);
                }
            }
        </script>
        <style id="dockStyles" type="text/css" runat="server">
              
        </style>
    </telerik:RadCodeBlock>
</head>
<body>
    <form id="form1" runat="server" visible="True">
     <input id="lnkPopup" type="button" class="btnVeryBig" value="Add Widget" title="Add Widget" />
    <div id="modalRightCenterContent" style="display: none;">
        <div class="contentTableHeading">
            <asp:CheckBox ID="chkAlrmSumry" runat="server" />
            <asp:Label ID="alrmSuryLbl" runat="server" Text="Alarm Summary"/><br />
            <asp:CheckBox ID="chkActCals" runat="server" />
            <asp:Label ID="actCalLbl" runat="server" Text="Active Calls"/><br />
            <asp:CheckBox ID="chkPndCals" runat="server" />
            <asp:Label ID="pndCalLbl" runat="server" Text="Pending Calls" /><br />
            <asp:CheckBox ID="chkCalActConsole" runat="server"/>
            <asp:Label ID="calActCnslLbl" runat="server" Text="Call Activity for Active Consoles" /><br />
            <asp:CheckBox ID="chkDisptchr" runat="server"/>
            <asp:Label ID="Label1" runat="server" Text="Call Activity for Active Dispatchers"/><br />
            <asp:CheckBox ID="chkCalActEndpnt" runat="server"/>
            <asp:Label ID="calActEndpntLbl" runat="server" Text="Call Activity for Active Endpoints"/><br />            
        </div>
        <div class="buttonHolder">
            <input type="button" id="btnAdd" value="Add Widget" class="btnMedium " title="Add Widget" />            
            <input type="button" id="btnCancel" value="Cancel" class="btnSmall marginActionButton"
                title="Cancel" />
        </div>
    </div>
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadDockLayout1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="chkAlrmSumry" LoadingPanelID="DefaultLoadingPanelID "
                        UpdatePanelRenderMode="Inline" />
                    <telerik:AjaxUpdatedControl ControlID="chkActCals" LoadingPanelID="DefaultLoadingPanelID "
                        UpdatePanelRenderMode="Inline" />
                    <telerik:AjaxUpdatedControl ControlID="chkPndCals" LoadingPanelID="DefaultLoadingPanelID "
                        UpdatePanelRenderMode="Inline" />
                    <telerik:AjaxUpdatedControl ControlID="chkCalActConsole" LoadingPanelID="DefaultLoadingPanelID "
                        UpdatePanelRenderMode="Inline" />
                   <telerik:AjaxUpdatedControl ControlID="chkDisptchr" LoadingPanelID="DefaultLoadingPanelID "
                        UpdatePanelRenderMode="Inline" />
                    <telerik:AjaxUpdatedControl ControlID="chkCalActEndpnt" LoadingPanelID="DefaultLoadingPanelID "
                        UpdatePanelRenderMode="Inline" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <asp:UpdatePanel ID="Panel1" runat="server" Visible="True">
        <ContentTemplate>
            <telerik:RadDockLayout runat="server" ID="RadDockLayout1" OnLoadDockLayout="RadDockLayout1_LoadDockLayout"
                OnSaveDockLayout="RadDockLayout1_SaveDockLayout">
                <div style="width: 100%;">
                    <div align="left" style="width: 72%; float: left">
                        <table align="left" class="style1">
                            <tr>
                                <td class="style6">
                                    <telerik:RadDockZone ID="RadDockZone1" runat="server" Height="165px" Width="300px">
                                    </telerik:RadDockZone>
                                </td>
                                <td class="style6">
                                    <telerik:RadDockZone ID="RadDockZone2" runat="server" Height="165px" Width="300px">
                                    </telerik:RadDockZone>
                                </td>
                                <td class="style6">
                                    <telerik:RadDockZone ID="RadDockZone3" runat="server" Height="165px" Width="300px">
                                    </telerik:RadDockZone>
                                </td>
                            </tr>
                            <tr>
                                <td class="style3">
                                    <telerik:RadDockZone ID="RadDockZone4" runat="server" Height="165px" Width="300px">
                                    </telerik:RadDockZone>
                                </td>
                                <td class="style3">
                                    <telerik:RadDockZone ID="RadDockZone5" runat="server" Height="165px" Width="300px">
                                    </telerik:RadDockZone>
                                </td>
                                <td class="style3">
                                    <telerik:RadDockZone ID="RadDockZone6" runat="server" Height="165px" Width="300px">
                                    </telerik:RadDockZone>
                                </td>
                            </tr>
                        </table>
                    </div>
                       
                </div>
            </telerik:RadDockLayout>
            <asp:HiddenField runat="server" ID="closedDockZoneId" />
            <%--stores the id of the RadDockZone, which holds the closed RadDock--%>
        </ContentTemplate>
    </asp:UpdatePanel>
  
    <%--Here goes the javascript for the popup--%>
    <script language="javascript" type="text/javascript">
        var popup = 0;
        $("#modalRightCenterContent").dialog({
            minHeight: 48,
            minWidth: 350,
            resizable: false,
            modal: true,
            autoOpen: false,
            title: "Add Widgets"
        })
        //        .parents(".ui-dialog").find(".ui-dialog-titlebar")
        //            .removeClass("ui-widget-header").addClass("titleBar");
        $("#lnkPopup").click(function () {
            $("#modalRightCenterContent").dialog('open');
        });
        $("#btnCancel").click(function () {
            $("#modalRightCenterContent").dialog('close');
            $("#chkAlrmSumry").removeAttr('checked');
            $("#chkActCals").removeAttr('checked');
            $("#chkPndCals").removeAttr('checked');
            $("#chkCalActConsole").removeAttr('checked');
            $("#chkDisptchr").removeAttr('checked');
            $("#chkCalActEndpnt").removeAttr('checked');
        });
        $("#btnAdd").click(function () {
            document.location.href = "DashBoard.aspx?Dock1Val=" + chkAlrmSumry.checked + "&Dock2Val=" + chkActCals.checked + "&Dock3Val=" + chkPndCals.checked + "&Dock4Val=" + chkCalActConsole.checked + "&Dock5Val=" + chkDisptchr.checked + "&Dock6Val=" + chkCalActEndpnt.checked + "";
            $("#modalRightCenterContent").dialog('close'); 
            $("#chkAlrmSumry").removeAttr('checked');
            $("#chkActCals").removeAttr('checked');
            $("#chkPndCals").removeAttr('checked');
            $("#chkCalActConsole").removeAttr('checked');
            $("#chkDisptchr").removeAttr('checked');
            $("#chkCalActEndpnt").removeAttr('checked');
        });
    </script>
    </form>
</body>
</html>

 aspx.cs
// ----------------------------------------
//  Copyright 2011 Avtec (Inc)
//
// This File has the implementation of DashBoard class methods.
//
//  Workfile:  DashBoard.aspx.cs
//  Revision:  1.0
//  Modified:  06/27/2011
//  All rights reserved. Copying, compilation, modification, distribution
//  or any other use whatsoever of this material is strictly prohibited
//  without the written consent of Avtec Inc.
// ----------------------------------------
  
  
/****************************************************************************/
/*!
*
*   @file DashBoard.aspx.cs
*
*   @brief Implements the Dashboard functionality
*
*/
/****************************************************************************/
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Telerik.Web.UI;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Web.Script.Serialization;
using System.Collections.ObjectModel;
  
/****************************************************************************/
/*!
*   @brief Implements the funtionality related to widgets in the Dashboard tab.
*   
*/
/****************************************************************************/
public partial class DashBoard_DashBoard : System.Web.UI.Page
{
    ////////////////////////////////////////////////////
    //
    //!func Page_Load()
    //
    //!output param - None
    //
    //!input param - object,EventArgs
    //
    //!brief - 
    //
    /////////////////////////////////////////////////////
  
    bool[] Dock_flag = { false, false, false, false, false,false};
    static RadDock[] zone1 = new RadDock[5];
    static RadDock[] zone2 = new RadDock[5];
    static RadDock[] zone3 = new RadDock[5];
    static RadDock[] zone4 = new RadDock[5];
    static RadDock[] zone5 = new RadDock[5];
    static RadDock[] zone6 = new RadDock[5];
  
    string result_dock = null;
    bool loadPageFlag = false;
  
    private List<DockState> CurrentDockStates
    {
        get
        {
            // Store the info about the added docks in the session.  
            List<DockState> _currentDockStates = (List<DockState>)Session["CurrentDockStatesDynamicDocks"];
            if (Object.Equals(_currentDockStates, null))
            {
                _currentDockStates = new List<DockState>();
                Session["CurrentDockStatesDynamicDocks"] = _currentDockStates;
            }
            return _currentDockStates;
        }
        set
        {
            Session["CurrentDockStatesDynamicDocks"] = value;
        }
    }
  
    protected override void OnInit(EventArgs e)
    {
        if (Session["DockFlags"] != null)
            Dock_flag = (bool[])Session["DockFlags"];
        for (int i = 0; i < CurrentDockStates.Count; i++)
        {
            if (CurrentDockStates[i].Closed == true)
            {
                RadDock dock = new RadDock();
                dock.Closed = true;
                dock.Visible = false;
                //RadDockLayout1.Controls.Remove(dock);
                CreateSaveStateTrigger(dock);
            }
  
            if (CurrentDockStates[i].Closed ==false)
            {
                RadDock dock = CreateRadDockFromState(CurrentDockStates[i]);
                RadDockLayout1.Controls.Add(dock);
                 CreateSaveStateTrigger(dock);
            }
        }
  
       
        if (!IsPostBack)
        {
              
            for (int i = 1; i <=6; i++)
            {
                result_dock = Request.QueryString["Dock" + i.ToString() + "Val"];
  
  
                if (result_dock != null && !result_dock.Equals(""))
                {
                    if (result_dock.Equals("true") && Dock_flag[i - 1] == false)
                    {
                        loadPageFlag = true;
                        RadDock dock = CreateRadDock(i);
                        // RadDock dock = new RadDock();
                        AddToEmptyRadDock(dock);                       
                        CreateSaveStateTrigger(dock);
                        Dock_flag[i - 1] = true;
                        Session["DockFlags"] = Dock_flag;      
                         
                          
                    }
                }
            }
        }
    }
  
    public void AddToEmptyRadDock(RadDock dock)
    {
        if (RadDockZone1.Docks.Count == 0)
        {
            RadDockZone1.Controls.Add(dock);
  
        }
  
        else
   
        if (RadDockZone2.Docks.Count == 0)
        {
            RadDockZone2.Controls.Add(dock);
        }
  
        else 
        if (RadDockZone3.Docks.Count == 0)
        {
            RadDockZone3.Controls.Add(dock);
        }
  
        else 
        if (RadDockZone4.Docks.Count == 0)
        {
            RadDockZone4.Controls.Add(dock);
        }
  
        else 
        if (RadDockZone5.Docks.Count == 0)
        {
            RadDockZone5.Controls.Add(dock);
        }
  
        else
              
        if (RadDockZone6.Docks.Count == 0)
        {
            RadDockZone6.Controls.Add(dock);
        }
    }
  
    private RadDock CreateRadDockFromState(DockState state)
    {
        RadDock dock = new RadDock();
        dock.DockMode = DockMode.Default;
        dock.EnableAnimation = true;
        dock.EnableRoundedCorners = true;
        dock.EnableTheming = true;
        dock.Skin = "Web20";
        dock.Height = Unit.Pixel(165);
        dock.Width = Unit.Pixel(300);
        dock.ID = string.Format("{0}", state.UniqueName);
        dock.ApplyState(state);
        dock.Resizable = true;
        DockCloseCommand closeCommand = new DockCloseCommand();
        closeCommand.AutoPostBack = true;
        DockExpandCollapseCommand expandCommand = new DockExpandCollapseCommand();
        expandCommand.AutoPostBack = false;
        DockToggleCommand maximizeCommand = new DockToggleCommand();
        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.Overflow, "hidden"); 
  
        switch (state.Title.ToString())
        {
            case "Alarm Summary":
  
                                Control widget = LoadControl("Controls/AlarmSummaryCtrl.ascx");
                                dock.Command += new DockCommandEventHandler(this.Dock1_Command);
                                dock.Commands.Add(closeCommand);
                                dock.Command += new DockCommandEventHandler(this.dockmax1_Command);
                                dock.Commands.Add(maximizeCommand);
                                dock.Commands.Add(expandCommand);
                                chkAlrmSumry.Enabled = false;
                                dock.ContentContainer.Controls.Add(widget);
                                dock.ContentContainer.Style.Add(HtmlTextWriterStyle.Overflow, "hidden"); 
                                break;
  
            case "Active Calls":
  
                                widget = LoadControl("Controls/ActiveCallsCtrl.ascx");
                                dock.Command += new DockCommandEventHandler(this.Dock2_Command);
                                dock.Commands.Add(closeCommand);
                                dock.Command += new DockCommandEventHandler(this.dockmax2_OnCommand);
                                dock.Commands.Add(maximizeCommand);
                                dock.Commands.Add(expandCommand);
                                chkActCals.Enabled = false;
                                dock.ContentContainer.Controls.Add(widget);
                                dock.ContentContainer.Style.Add(HtmlTextWriterStyle.Overflow, "hidden"); 
                                break;
  
            case "Pending Calls":
  
                                widget = LoadControl("Controls/PendingCallsCtrl.ascx");
                                dock.Command += new DockCommandEventHandler(this.Dock3_Command);
                                dock.Commands.Add(closeCommand);
                                dock.Command += new DockCommandEventHandler(this.dockmax3_Command);
                                dock.Commands.Add(maximizeCommand);
                                dock.Commands.Add(expandCommand);
                                chkPndCals.Enabled = false;
                                dock.ContentContainer.Controls.Add(widget);
                                dock.ContentContainer.Style.Add(HtmlTextWriterStyle.Overflow, "hidden");             
                                break;
  
            case "Call Activity for Active Consoles":
  
                                widget = LoadControl("Controls/CallActivityForConoleCtrl.ascx");
                                dock.Command += new DockCommandEventHandler(this.Dock4_Command);
                                dock.Commands.Add(closeCommand);
                                dock.Command += new DockCommandEventHandler(this.dockmax4_Command);
                                dock.Commands.Add(maximizeCommand);
                                dock.Commands.Add(expandCommand);
                                chkCalActConsole.Enabled = false;
                                dock.ContentContainer.Controls.Add(widget);
                                dock.ContentContainer.Style.Add(HtmlTextWriterStyle.Overflow, "hidden"); 
  
                                break;
  
            case "Call Activity for Active Dispatchers":
  
                                widget = LoadControl("Controls/CallActivityForDispatchrCtrl.ascx");
                                dock.Command += new DockCommandEventHandler(this.Dock5_Command);
                                dock.Commands.Add(closeCommand);
                                dock.Command += new DockCommandEventHandler(this.dockmax5_Command);
                                dock.Commands.Add(maximizeCommand);
                                dock.Commands.Add(expandCommand);
                                chkDisptchr.Enabled = false;
                                dock.ContentContainer.Controls.Add(widget);
                                dock.ContentContainer.Style.Add(HtmlTextWriterStyle.Overflow, "hidden"); 
                                break;
  
            case "Call Activity for Active Endpoints":
  
                                widget = LoadControl("Controls/CallActivityForEndPntCtrl.ascx");
                                dock.Command += new DockCommandEventHandler(this.Dock6_Command);
                                dock.Commands.Add(closeCommand);
                                dock.Command += new DockCommandEventHandler(this.dockmax6_Command);
                                dock.Commands.Add(maximizeCommand);
                                dock.Commands.Add(expandCommand);
                                chkCalActEndpnt.Enabled = false;
                                dock.ContentContainer.Controls.Add(widget);
                                dock.ContentContainer.Style.Add(HtmlTextWriterStyle.Overflow, "hidden"); 
                                break;
        }        
        
        return dock;
    }
  
    private RadDock CreateRadDock(int i)
    {
        RadDock dock = new RadDock();
        dock.DockMode = DockMode.Default;
        dock.EnableAnimation = true;
        dock.EnableRoundedCorners = true;
        dock.EnableTheming = true;
        dock.Skin = "Web20";
        dock.Resizable = true;
        dock.UniqueName = Guid.NewGuid().ToString();
        dock.ID = string.Format("RadDock{0}", dock.UniqueName);
        //dock.Title = "Dock" + i.ToString();
  
        switch (i)
        {
            case 1:
                dock.Title = "Alarm Summary";
                break;
            case 2:
                dock.Title = "Active Calls";
                break;
            case 3:
                dock.Title = "Pending Calls";
                break;
            case 4:
                dock.Title = "Call Activity for Active Consoles";
                break;
            case 5:
                dock.Title = "Call Activity for Active Dispatchers";
                break;
            case 6:
                dock.Title = "Call Activity for Active Endpoints";
                break;
        }
  
        dock.Height = Unit.Pixel(165);
        dock.Width = Unit.Pixel(300);        
        //assign client-side event handler
        dock.OnClientInitialize = "Dock_OnClientInitialize";
        DockCloseCommand closeCommand = new DockCloseCommand();
        closeCommand.AutoPostBack = true;
        DockToggleCommand maximizeCommand = new DockToggleCommand();
        maximizeCommand.Text = "Maximize";
        maximizeCommand.OnClientCommand = "Dock_OnMaximizeCommand";
        maximizeCommand.AlternateText = "Restore";
        maximizeCommand.CssClass = "max";
        DockExpandCollapseCommand expandCommand = new DockExpandCollapseCommand();
        dock.OnClientCommand = "ClientCommand";
  
        switch (dock.Title.ToString())
        {
            case "Alarm Summary":
  
                Control widget = LoadControl("~/DashBoard/Controls/AlarmSummaryCtrl.ascx");
                dock.Command += new DockCommandEventHandler(this.Dock1_Command);
                dock.Commands.Add(closeCommand);
                dock.Command += new DockCommandEventHandler(this.dockmax1_Command);
                dock.Commands.Add(maximizeCommand);
                dock.ContentContainer.Controls.Add(widget);
                break;
  
            case "Active Calls":
  
                widget = LoadControl("~/DashBoard/Controls/ActiveCallsCtrl.ascx");
                dock.Command += new DockCommandEventHandler(this.Dock2_Command);
                dock.Commands.Add(closeCommand);
                dock.Command += new DockCommandEventHandler(this.dockmax2_OnCommand);
                dock.Commands.Add(maximizeCommand);
                dock.ContentContainer.Controls.Add(widget);
                dock.ContentContainer.Style.Add(HtmlTextWriterStyle.Overflow, "hidden"); 
                break;
  
            case "Pending Calls":
  
                widget = LoadControl("~/DashBoard/Controls/PendingCallsCtrl.ascx");
                dock.Command += new DockCommandEventHandler(this.Dock3_Command);
                dock.Commands.Add(closeCommand);
                dock.Command += new DockCommandEventHandler(this.dockmax3_Command);
                dock.Commands.Add(maximizeCommand);
                dock.ContentContainer.Controls.Add(widget);
                dock.ContentContainer.Style.Add(HtmlTextWriterStyle.Overflow, "hidden"); 
                break;
  
            case "Call Activity for Active Consoles":
  
                widget = LoadControl("~/DashBoard/Controls/CallActivityForConoleCtrl.ascx");
                dock.Command += new DockCommandEventHandler(this.Dock4_Command);
                dock.Commands.Add(closeCommand);
                dock.Command += new DockCommandEventHandler(this.dockmax4_Command);
                dock.Commands.Add(maximizeCommand);
                dock.ContentContainer.Controls.Add(widget);
                dock.ContentContainer.Style.Add(HtmlTextWriterStyle.Overflow, "hidden"); 
                break;
  
            case "Call Activity for Active Dispatchers":
  
                widget = LoadControl("~/DashBoard/Controls/CallActivityForDispatchrCtrl.ascx");
                dock.Command += new DockCommandEventHandler(this.Dock5_Command);
                dock.Commands.Add(closeCommand);
                dock.Command += new DockCommandEventHandler(this.dockmax5_Command);
                dock.Commands.Add(maximizeCommand);
                dock.ContentContainer.Controls.Add(widget);
                dock.ContentContainer.Style.Add(HtmlTextWriterStyle.Overflow, "hidden"); 
                break;
  
            case "Call Activity for Active Endpoints":
  
                widget = LoadControl("~/DashBoard/Controls/CallActivityForEndPntCtrl.ascx");
                dock.Command += new DockCommandEventHandler(this.Dock6_Command);
                dock.Commands.Add(closeCommand);
                dock.Command += new DockCommandEventHandler(this.dockmax6_Command);
                dock.Commands.Add(maximizeCommand);
                dock.ContentContainer.Controls.Add(widget);
                dock.ContentContainer.Style.Add(HtmlTextWriterStyle.Overflow, "hidden"); 
                break;
        }
               
        return dock;
    }
  
    private void CreateSaveStateTrigger(RadDock dock)
    {
        // Ensure that the RadDock control will initiate postback when its position changes on the client or any of the commands is clicked.  
        // Using the trigger we will "ajaxify" that postback.   
        dock.AutoPostBack = true;
        dock.CommandsAutoPostBack = true;
    }
  
    protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e)
    {
        foreach (DockState state in CurrentDockStates)
        {
            e.Positions[state.UniqueName] = state.DockZoneID;
            e.Indices[state.UniqueName] = state.Index;
        }
        return;
    }
  
    protected void RadDockLayout1_SaveDockLayout(object sender, DockLayoutEventArgs e)
    {
        CurrentDockStates = new List<DockState>();
  
        foreach (DockState ds in RadDockLayout1.GetRegisteredDocksState())
        {
            CurrentDockStates.Add(ds);
            Session["DockFlags"] = Dock_flag;
        }
  
        if (loadPageFlag)
        {
            Page.ClientScript.RegisterStartupScript(typeof(Page), "reloadPage", "<script type='text/javascript'>window.location.href = 'DashBoard.aspx';</script>");
            loadPageFlag = false;
        }
    }   
  
    protected void Dock1_Command(object sender, DockCommandEventArgs e)
    {
        if (e.Command.Name.Equals("Close"))
        {
            Dock_flag[0] = false;
            RadDock rad = (RadDock)sender;
            rad.Undock();
            rad.Dispose();
            Refresh();
            chkAlrmSumry.Enabled = true;
        }
    }
     
    protected void Dock2_Command(object sender, DockCommandEventArgs e)
    {
        if (e.Command.Name.Equals("Close"))
        {
            Dock_flag[1] = false;
            RadDock rad = (RadDock)sender;
            rad.Undock();
            rad.Dispose();
            Refresh();
            chkActCals.Enabled = true;
        }
    }
  
    protected void Dock3_Command(object sender, DockCommandEventArgs e)
    {
        if (e.Command.Name.Equals("Close"))
        {
            Dock_flag[2] = false;
            RadDock rad = (RadDock)sender;
            rad.Undock();
            rad.Dispose();
            Refresh();
            chkPndCals.Enabled = true;
        }
    }
  
    protected void Dock4_Command(object sender, DockCommandEventArgs e)
    {
        if (e.Command.Name.Equals("Close"))
        {
            Dock_flag[3] = false;
            RadDock rad = (RadDock)sender;
            rad.Undock();
            rad.Dispose();
            Refresh();
            chkCalActConsole.Enabled = true;
        }
    }
  
    protected void Dock5_Command(object sender, DockCommandEventArgs e)
    {
        if (e.Command.Name.Equals("Close"))
        {
            Dock_flag[4] = false;
            RadDock rad = (RadDock)sender;
            rad.Undock();
            rad.Dispose();
            Refresh();
            chkDisptchr.Enabled = true;
        }
    }
  
    protected void Dock6_Command(object sender, DockCommandEventArgs e)
    {
        if (e.Command.Name.Equals("Close"))
        {
            Dock_flag[5] = false;
            RadDock rad = (RadDock)sender;
            rad.Undock();
            rad.Dispose();
            Refresh();
            chkCalActEndpnt.Enabled = true;
        }
    }
  
    protected void moveToDock(RadDockZone fromDock, RadDockZone toDock)
    {
        for (int i = fromDock.Docks.Count - 1; i >= 0; i--)
        {
            fromDock.Docks[i].DockZoneID = toDock.ID;
        }
    }
  
    protected void Refresh()
    {
        // int closedDockZoneIndex = Int32.Parse(closedDockZoneId.Value.Substring(11, 1));  
        for (int i = 1; i < RadDockLayout1.RegisteredZones.Count; i++)
        {
            for (int j = 0; j < i; j++)
            {
                if (RadDockLayout1.RegisteredZones[j].Docks.Count == 0)
                {
                    moveToDock(RadDockLayout1.RegisteredZones[i], RadDockLayout1.RegisteredZones[j]);
                    break;
                }
            }
        }
    }
  
    protected void dockmax1_Command(object sender, DockCommandEventArgs e)
    {
    }
  
    protected void dockmax2_OnCommand(object sender, DockCommandEventArgs e)
    {
    }
  
    protected void dockmax3_Command(object sender, DockCommandEventArgs e)
    {
    }
  
    protected void dockmax4_Command(object sender, DockCommandEventArgs e)
    {
    }
      
    protected void dockmax5_Command(object sender, DockCommandEventArgs e)
    {
    }
  
    protected void dockmax6_Command(object sender, DockCommandEventArgs e)
    {
    }
      
}

Can any once solve my problem its ungent for me pleasee
0
Slav
Telerik team
answered on 14 Sep 2011, 05:03 PM
Hi Ram,

Please refer to your support ticket, with the attached sample project on the matter, for a solution of your issue.

I noticed that you have opened a support ticket and you have written in one additional forum thread about the same problem. For future use of our support system, please use a separate ticket for every issue you want to report. This way our communication will be easier to follow and we'll be able to provide answers to your request much faster. My suggestion is to continue our discussion in the support ticket, containing your sample project.


All the best,
Slav
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
Tags
Dock
Asked by
Jains
Top achievements
Rank 1
Answers by
Pero
Telerik team
Jains
Top achievements
Rank 1
Ram
Top achievements
Rank 1
Slav
Telerik team
Share this question
or