Dock Position in the DockZone

3 posts, 0 answers
  1. Evgeniy
    Evgeniy avatar
    17 posts
    Member since:
    Sep 2008

    Posted 02 Dec 2008 Link to this post


    I have table in Database with fields: id, title, text, position.

    Every record in table it is RadDock control.

    I need on load page add RadDock Control in RadZone with position from database.
    I can add RadDock in RadZone, but position RadDock is not position from database.

    How I can make it?

    my aspx file:
    <telerik:RadDockLayout ID="RadDockLayout1" runat="server" OnLoadDockLayout="RadDockLayout1_LoadDockLayout" 
                OnSaveDockLayout="RadDockLayout1_SaveDockLayout" Skin="Vista"
                <div style="float:left;"
                    <telerik:RadDockZone ID="rdZone" runat="server" Height="100%" Skin="Vista" Width="500px"

    my cs file:
    protected void Page_Init(object sender, EventArgs e)  
            if (!IsPostBack)  
                //data - this is DataSet; da - this is DataAdapter  
                for (int i = 0; i < data.Rows.Count; i++)  
                    RadDock dock = CreateRadDock(data[i].Title, data[i].Text, data[i].Id, data[i].Position-1);  
                            string.Format(@"function _addDock() {{  
                                Sys.Application.add_load(_addDock);", dock.ClientID, rdZone.ClientID),  
            for (int i = 0; i < CurrentDockStates.Count; i++)  
                RadDock dock = CreateRadDockFromState(CurrentDockStates[i]);  
    private List<DockState> CurrentDockStates 
                List<DockState> _currentDockStates = (List<DockState>)Session["CurrentDockStatesDynamicDocks"]; 
                if (Object.Equals(_currentDockStates, null)) 
                    _currentDockStates = new List<DockState>(); 
                    Session["CurrentDockStatesDynamicDocks"] = _currentDockStates; 
                return _currentDockStates; 
                Session["CurrentDockStatesDynamicDocks"] = value; 
        private RadDock CreateRadDockFromState(DockState state) 
            RadDock dock = new RadDock(); 
            dock.ID = string.Format("RadDock{0}", state.UniqueName); 
            dock.DefaultCommands = Telerik.Web.UI.Dock.DefaultCommands.ExpandCollapse; 
            dock.Style.Add("padding-bottom", "10px"); 
            return dock; 
        private RadDock CreateRadDock(string title, string text, int id, int position) 
            int docksCount = CurrentDockStates.Count; 
            RadDock dock = new RadDock(); 
            dock.UniqueName = Guid.NewGuid().ToString(); 
            dock.ID = string.Format("RadDock{0}", dock.UniqueName); 
            dock.Title = title
            dock.Text = text
            dock.Skin = "Vista"
            dock.Style.Add("padding-bottom", "10px"); 
            dock.Collapsed = true
            dock.DefaultCommands = Telerik.Web.UI.Dock.DefaultCommands.ExpandCollapse; 
            dock.Attributes.Add("id", id.ToString()); 
            return dock; 
        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; 
        protected void RadDockLayout1_SaveDockLayout(object sender, DockLayoutEventArgs e) 
            CurrentDockStates = RadDockLayout1.GetRegisteredDocksState(); 


  2. Petko
    Petko avatar
    45 posts

    Posted 02 Dec 2008 Link to this post

    Hello Evgeniy,

    You can see how to save/load dockstate from DB in this forum:
    Check the post of Sophy, where she sent an attached project, that demonstrates how to achieve the desired scenario.
    Hope this helps you.

    Sincerely yours,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. tieu
    tieu avatar
    1 posts
    Member since:
    Dec 2008

    Posted 29 May 2009 Link to this post

    add 1 row to save name of RadDock, 1 row to save name of RadDockZone (want add RadDock when program run)
    When you Load Data in database to Page, you must done:

    //Get Data in database --> add to Table
     DataTable tbl = GetData();

                if (tbl != null && tbl.Rows.Count > 0)
                    foreach (DataRow row in tbl.Rows)
                        string radDockName = row["Control"].ToString();
                        RadDock radDock = (RadDock)FindControl(radDockName);
                        if (radDock != null)
                            radDock.UniqueName = row["Control"].ToString();
                            radDock.ID = radDockName;
                            String Zone =ReplaceText(row["LayoutPosition"].ToString());
                            int Index = Convert.ToInt32(row["position"].ToString());
    //if you want drag and drop control :                           
                                radDock.DockHandle = DockHandle.Grip;
                                radDock.DockMode = DockMode.Docked;      
    //if you don't want drag and drop control: set DockHandle = DockHandle.None;          

                            DockState state = new DockState();
                            state.UniqueName = radDockName;
                            state.DockZoneID = row["LayoutPosition"].ToString();
                            state.Index = Index

    Hope this helps you.
Back to Top