Can not remove dock commands in any loops

2 posts, 0 answers
  1. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 16 Apr 2011 Link to this post

    Hi,
    When i removing dock command direct like "dock.commands.remove(0)" than it will remove 0th index command, but when i will put this remove statement in loop it will not work properly.

    CREATE TABLE [dbo].[Widgets](
        [WidgetsID] [int] IDENTITY(1,1) NOT NULL,
        [WidgetsName] [nvarchar](max) NOT NULL,
        [WidgetsUrl] [nvarchar](max) NULL,
        [Description] [nvarchar](max) NULL,
        [StatusID] [int] NOT NULL,
        [CreatedByID] [int] NOT NULL,
        [CreatedByDate] [datetime] NOT NULL,
        [ModifiedByID] [int] NULL,
        [ModifiedByDate] [datetime] NULL,
     CONSTRAINT [PK_Widgets] PRIMARY KEY CLUSTERED 
    (
        [WidgetsID] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
      
    GO
    -----------------------------------------------------------
    CREATE TABLE [dbo].[WidgetsPersonalized](
        [WidgetsPersonalizedID] [int] IDENTITY(1,1) NOT NULL,
        [EmpNo] [int] NOT NULL,
        [WidgetsID] [nvarchar](50) NULL,
        [DockString] [nvarchar](max) NULL,
        [StatusID] [int] NOT NULL,
        [CreatedByID] [int] NOT NULL,
        [CreatedByDate] [datetime] NOT NULL,
        [ModifiedByID] [int] NULL,
        [ModifiedByDate] [datetime] NULL,
     CONSTRAINT [PK_WidgetsPersonalized] PRIMARY KEY CLUSTERED 
    (
        [WidgetsPersonalizedID] ASC,
        [EmpNo] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    GO
    --------------------------------------------------
    --  exec usp_DeleteWidgets 1,'Branch Status',''
    CREATE Procedure [dbo].[usp_DeleteWidgets]
    (
        @EmpNo as int,
        @DockTitle as nvarchar(MAX), 
        @ReturnVal int output
    )
    as
    Begin
        set @ReturnVal = 0
        declare @temptable TABLE (items varchar(8000))
        declare @Delimiter char(1)
        set @Delimiter = ','
          
        Declare @WidgetsID as varchar(20)
        Declare @WidgetsList as varchar(MAX)
        Declare @NewWidgetsList as varchar(MAX)
        Declare @MaxRecordExist as int
          
        -- get WidgetsID from Widgets using WidgetsName
        set @WidgetsID = (select cast(WidgetsID as varchar(20))as WidgetsID from Widgets 
        where upper(ltrim(rtrim(WidgetsName))) = upper(ltrim(rtrim(@DockTitle))))
          
        -- Get List of Existing Widgets for perticuler employee
        set @WidgetsList = (select WidgetsID from WidgetsPersonalized where EmpNo = @EmpNo)
          
        -- Split Existing Widgets list and insert it into TempTable.
        insert into @temptable (Items)
        select Items from dbo.Split(@WidgetsList,@Delimiter)
          
        -- Check if Only one record exist for the user than delete the record.
        -- else Update the exist widgets list.
        set @MaxRecordExist = (Select Count(*) from @temptable) 
        print @MaxRecordExist
        if(@MaxRecordExist = 1)
        Begin
            delete from WidgetsPersonalized where EmpNo = @EmpNo
            set @ReturnVal = 1
        End
        else
        Begin       
            select @NewWidgetsList = COALESCE(@NewWidgetsList + @Delimiter,'') + Items from @temptable
            where not (charIndex(',' + rtrim(cast(Items  as nvarchar(max))) + ',',',' + isnull(@WidgetsID,-1) +',') >0 ) 
            print @NewWidgetsList
            update WidgetsPersonalized 
            set WidgetsID = isnull(@NewWidgetsList,WidgetsID)where EmpNo = @EmpNo   
            set @ReturnVal = 1
        End 
    End
      
    GO
      
      
    ------------------------------
    CREATE Procedure [dbo].[usp_InsertWidgetsPersonalized]  
    (  
     @WidgetsPersonalizedID int,  
     @EmpNo int,  
     @WidgetsID nvarchar(50),  
     @DockString nvarchar(MAX),  
     @StatusID int,  
     @CreatedByID int,  
     @ReturnVal int output  
    )  
    as  
    Begin  
    set @ReturnVal = 0  
    select @WidgetsPersonalizedID = WidgetsPersonalizedID from WidgetsPersonalized where EmpNo = @EmpNo  
        --if(@WidgetsID is not null)
        --Begin
            if(@WidgetsPersonalizedID > 0)  
            Begin 
                Declare @WidgetsIDExist int
                select @WidgetsIDExist = Count(*) from dbo.Split((select WidgetsID from WidgetsPersonalized where EmpNo = @EmpNo),',')
                where Items = @WidgetsID        
              
                Update WidgetsPersonalized  
                set WidgetsID =case when @WidgetsID is not null and @WidgetsIDExist = 0 then (ltrim(rtrim(WidgetsID))+','+@WidgetsID) else ltrim(rtrim(WidgetsID)) end,
                DockString = isnull(@DockString,DockString),  
                StatusID = isnull(@StatusID,StatusID),  
                ModifiedByID = isnull(@CreatedByID,ModifiedByID),  
                ModifiedByDate = getdate()  
                where EmpNo = @EmpNo     
                set @ReturnVal = 1  
            End  
            else  
            Begin  
                if(@WidgetsID is not null)
                Begin
                    Insert into WidgetsPersonalized   
                    (EmpNo,WidgetsID,DockString,StatusID, CreatedByID,CreatedByDate,ModifiedByID,ModifiedByDate)  
                    values(@EmpNo, @WidgetsID, @DockString, @StatusID, @CreatedByID,GetDate(),@CreatedByID,GetDate())  
                    set @ReturnVal = 1    
                End
            End  
        --End
    End
    GO
      
      
    ----------------------------------
    -- exec usp_SelectWidgets 1,null
    CREATE procedure [dbo].[usp_SelectWidgets]
    (
        @EmpNo int,
        @StatusID int
    )
    as
    Begin
        Declare @WidgetsID as varchar(20)
        select @WidgetsID = WidgetsID from WidgetsPersonalized where EmpNo = @EmpNo
        select WidgetsID,WidgetsName,WidgetsUrl,[Description],StatusID,CreatedByID,
        CreatedByDate,ModifiedByID,ModifiedByDate from Widgets 
        where StatusID = isnull(@StatusID,StatusID) and 
        not (charIndex(',' + rtrim(cast(WidgetsID  as nvarchar(max))) 
        + ',',',' + isnull(@WidgetsID,-1) +',') >0 )    
    End
      
      
    GO
      
      
    ------------------------------------
    -- exec usp_SelectWidgetsPersonalized null
    CREATE procedure [dbo].[usp_SelectWidgetsPersonalized]
    (
        @EmpNo int,
        @StatusID int
    )
    as
    Begin
        select WidgetsPersonalizedID,EmpNo,WidgetsID,DockString,StatusID,CreatedByID,
        CreatedByDate,ModifiedByID,ModifiedByDate from WidgetsPersonalized
        where StatusID = isnull(@StatusID,StatusID) and EmpNo = isnull(@EmpNo,EmpNo)
    End
    GO
      
      
    ----------------------------------------
    <%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
        CodeFile="Default.aspx.cs" Inherits="Default" %>
      
    <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
        <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="lnkBtnAddWidgets">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="dlDashBoard" LoadingPanelID="radloadingpanal" />
                        <telerik:AjaxUpdatedControl ControlID="ddlWidgets" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="lnkBtnClose">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="dlDashBoard" LoadingPanelID="radloadingpanal" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="dlDashBoard">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="dlDashBoard" LoadingPanelID="radloadingpanal" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManagerProxy>
        <%-- <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
            <script language="javascript" type="text/javascript">
                function ImgChange(ControlID, TitleContent) {
                    $("#" + TitleContent).slideToggle(500);
                    if (ControlID.className == "collapsibleUP") {
                        ControlID.setAttribute("class", "collapsibleDown");
                    }
                    else {
                        ControlID.setAttribute("class", "collapsibleUP");
      
                    }
                }
            </script>
        </telerik:RadScriptBlock>--%>
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
        <table cellpadding="0" cellspacing="2" border="0" style="width: 100%">
            <tr>
                <td align="right">
                    <asp:LinkButton ID="lnkBtnPersonalizePage" runat="server" Text="Personalize this page My page"
                        class="collapsibleDown" OnClick="lnkBtnPersonalizePage_Click"></asp:LinkButton>
                    <asp:Panel ID="pnlAddWidgets" runat="server" Visible="false">
                        <table cellpadding="0" cellspacing="2" border="0">
                            <tr valign="middle" align="right">
                                <td>
                                    <telerik:RadComboBox ID="ddlWidgets" runat="server" DataTextField="WidgetsName" DataValueField="WidgetsID">
                                    </telerik:RadComboBox>
                                </td>
                                <td>
                                    <telerik:RadComboBox ID="ddlPosition" runat="server">
                                        <Items>
                                            <telerik:RadComboBoxItem Selected="true" Text="Select Position" Value="-1" />
                                            <telerik:RadComboBoxItem Text="Top" Value="TOP" />
                                            <telerik:RadComboBoxItem Text="Right" Value="RIGHT" />
                                            <telerik:RadComboBoxItem Text="Left" Value="LEFT" />
                                        </Items>
                                    </telerik:RadComboBox>
                                </td>
                                <td align="right" rowspan="2">
                                    <asp:LinkButton ID="lnkBtnAddWidgets" runat="server" Text="Add" CssClass="IconAdd"
                                        OnClick="lnkBtnAddWidgets_Click"></asp:LinkButton>
                                </td>
                                <td align="right" rowspan="2">
                                    <asp:LinkButton ID="lnkBtnClose" runat="server" Text="Close" CssClass="IconBack"
                                        OnClick="lnkBtnClose_Click"></asp:LinkButton>
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </td>
            </tr>
        </table>
        <%--        <tr>
                <td align="center" valign="top">--%>
        <telerik:RadDockLayout ID="dlDashBoard" runat="server" OnLoadDockLayout="dlDashBoard_LoadDockLayout"
            OnSaveDockLayout="dlDashBoard_SaveDockLayout">
            <table cellpadding="4" cellspacing="4" style="width: 100%" border="0">
                <tr valign="top">
                    <td colspan="2">
                        <telerik:RadDockZone ID="dzTop" runat="server" Width="100%" Height="100%" BorderStyle="None">
                        </telerik:RadDockZone>
                    </td>
                </tr>
                <tr valign="top">
                    <td style="width: 50%">
                        <telerik:RadDockZone ID="dzLeft" runat="server" Width="100%" Height="100%" BorderStyle="None">
                        </telerik:RadDockZone>
                    </td>
                    <td style="width: 50%">
                        <telerik:RadDockZone ID="dzRight" runat="server" Width="100%" Height="100%" BorderStyle="None">
                        </telerik:RadDockZone>
                    </td>
                </tr>
            </table>
            <div style="display: none">
                <asp:UpdatePanel runat="server" ID="UpdatePanel1">
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="lnkBtnAddWidgets" EventName="Click" />
                    </Triggers>
                </asp:UpdatePanel>
            </div>
        </telerik:RadDockLayout>
        <%-- </td>
            </tr>--%>
    </asp:Content>
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Test.Domain;
    using Test.DataModel;
    using Telerik.Web.UI;
    using System.Text;
    using System.Drawing;
    public partial class Default : System.Web.UI.Page
    {
        public static List<usp_SelectWidgetsResult> lstWidgets;
        public static int intEmpNo = 1;
        private string _NewWidgetID;
        public string NewWidgetID
        {
            get { return _NewWidgetID != null ? _NewWidgetID : null; }
            set { _NewWidgetID = value; }        
        }
        private bool _IsDeleted;
        public bool IsDeleted
        {
            get { return _IsDeleted; }
            set { _IsDeleted = value; }
            //get { return ViewState["NewWidgetID"] != null ? ViewState["NewWidgetID"].ToString() : null; }
            //set { ViewState["NewWidgetID"] = value; }
        }
        private int _count = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                intEmpNo = 1;
                BindDropDown();
                SetDockZoneStyle(true, Color.Gray, BorderStyle.None);
            }
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            string dockState = "";
            lstWidgets = new DashboardDO().SelectWidgets(null, null);
            List<usp_SelectWidgetsPersonalizedResult> WPList = new DashboardDO().SelectWidgetsPersonalized(intEmpNo, null);
            if (WPList.Count > 0)
            {
                dockState = WPList[0].DockString;
            }
            string[] currentDockStates = dockState.Split('|');
            _count = currentDockStates.Length;
            //Recreate the docks in order to ensure their proper operation
            for (int i = 0; i < _count; i++)
            {
                if (currentDockStates[i].Trim() != string.Empty)
                {
                    RadDock dock = CreateRadDockFromState(currentDockStates[i]);
                    dock.EnableAnimation = true;
                    if (lstWidgets.Where(w => w.WidgetsName.Trim().ToUpper() == dock.Title.Trim().ToUpper()).ToList().Count > 0)
                    {
                        dock.ContentContainer.Controls.Add(LoadControl(lstWidgets.Where(w => w.WidgetsName.Trim().ToUpper() == dock.Title.Trim().ToUpper()).ToList()[0].WidgetsUrl));
                    }
                    dlDashBoard.Controls.Add(dock);
                    CreateSaveStateTrigger(dock);
                }
            }
        }
        private void BindDropDown()
        {
            //if (lstWidgets.Count < 1)
            //{
            lstWidgets = new DashboardDO().SelectWidgets(intEmpNo, null);
            //}
            ddlWidgets.Items.Clear();
            ddlWidgets.DataSource = lstWidgets;
            ddlWidgets.DataBind();
            ddlWidgets.Items.Add(new RadComboBoxItem("Select Widget", "-1"));
            ddlWidgets.SelectedValue = "-1";
        }
        private RadDock CreateRadDockFromState(string stringState)
        {
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            DockState state = serializer.Deserialize<DockState>(stringState);
            RadDock dock = new RadDock();
            dock.ID = string.Format("RadDock{0}", state.UniqueName);
            dock.ApplyState(state);
            dock.EnableAnimation = true;
            dock.Command += new DockCommandEventHandler(dock_Command);
            dock.Commands.Add(new DockCloseCommand());
            dock.Commands.Add(new DockExpandCollapseCommand());
            return dock;
        }
        private void CreateSaveStateTrigger(RadDock dock)
        {
            dock.AutoPostBack = true;
            dock.CommandsAutoPostBack = true;
      
            AsyncPostBackTrigger saveStateTrigger = new AsyncPostBackTrigger();
            saveStateTrigger.ControlID = dock.ID;
            saveStateTrigger.EventName = "DockPositionChanged";
            UpdatePanel1.Triggers.Add(saveStateTrigger);
      
            saveStateTrigger = new AsyncPostBackTrigger();
            saveStateTrigger.ControlID = dock.ID;
            saveStateTrigger.EventName = "Command";
            UpdatePanel1.Triggers.Add(saveStateTrigger);
        }
        void dock_Command(object sender, DockCommandEventArgs e)
        {
            if (e.Command.Name == "Close")
            {
                ScriptManager.RegisterStartupScript(
                UpdatePanel1,
                this.GetType(),
                "RemoveDock",
                string.Format(@"function _removeDock() {{
        Sys.Application.remove_load(_removeDock);
        $find('{0}').undock();
        $get('{1}').appendChild($get('{0}'));
        $find('{0}').doPostBack('DockPositionChanged');
    }};
    Sys.Application.add_load(_removeDock);", ((RadDock)sender).ClientID, UpdatePanel1.ClientID),
                true);
      
                int val = new DashboardDO().DeleteWidgets(intEmpNo, ((RadDock)sender).Title.Trim());
                IsDeleted = true;
                CommonFunctions.DeleteMessage(this.Page, val, ((RadDock)sender).Title);
            }
        }
        protected void lnkBtnAddWidgets_Click(object sender, EventArgs e)
        {
            if (ddlWidgets.SelectedValue != "-1")
            {
                RadDock dock = CreateRadDock();
                UpdatePanel1.ContentTemplateContainer.Controls.Add(dock);
                NewWidgetID = ddlWidgets.SelectedValue;
                switch (ddlPosition.SelectedValue.ToUpper())
                {
                    case "TOP":
                        ScriptManager.RegisterStartupScript(
                          dock, this.GetType(), "AddDock", string.Format(@"function _addDock() {{
                                Sys.Application.remove_load(_addDock); $find('{1}').dock($find('{0}'));
                                $find('{0}').doPostBack('DockPositionChanged'); }};
                                Sys.Application.add_load(_addDock);", dock.ClientID, dzTop.ClientID), true);
                        break;
                    case "LEFT":
                        ScriptManager.RegisterStartupScript(
                          dock, this.GetType(), "AddDock", string.Format(@"function _addDock() {{
                                Sys.Application.remove_load(_addDock); $find('{1}').dock($find('{0}'));
                                $find('{0}').doPostBack('DockPositionChanged'); }};
                                Sys.Application.add_load(_addDock);", dock.ClientID, dzLeft.ClientID), true);
                        break;
                    case "RIGHT":
                        ScriptManager.RegisterStartupScript(
                          dock, this.GetType(), "AddDock", string.Format(@"function _addDock() {{
                                Sys.Application.remove_load(_addDock); $find('{1}').dock($find('{0}'));
                                $find('{0}').doPostBack('DockPositionChanged'); }};
                                Sys.Application.add_load(_addDock);", dock.ClientID, dzRight.ClientID), true);
                        break;
                }
                CreateSaveStateTrigger(dock);
            }
        }
        private RadDock CreateRadDock()
        {
            RadDock dock = new RadDock();
            string WidgetsURL = lstWidgets.Where(w => w.WidgetsID == Convert.ToInt32(ddlWidgets.SelectedValue)).ToList()[0].WidgetsUrl;
            dock.UniqueName = Guid.NewGuid().ToString();
            dock.ID = string.Format("RadDock{0}", dock.UniqueName);
            dock.Title = lstWidgets.Where(w => w.WidgetsID == Convert.ToInt32(ddlWidgets.SelectedValue)).ToList()[0].WidgetsName;
            dock.Width = Unit.Pixel(300);
            dock.EnableAnimation = true;
            dock.Commands.Add(new DockCloseCommand());
            dock.Commands.Add(new DockExpandCollapseCommand());
            dock.Command += new DockCommandEventHandler(dock_Command);
            dock.ContentContainer.Controls.Add(LoadControl(WidgetsURL));
            return dock;
        }
        protected void dlDashBoard_SaveDockLayout(object sender, DockLayoutEventArgs e)
        {
      
            string dockState;
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            List<DockState> stateList = dlDashBoard.GetRegisteredDocksState();
            StringBuilder serializedList = new StringBuilder();
            int i = 0;
            while (i < stateList.Count)
            {
                if (stateList[i].Closed == false)
                {
                    serializedList.Append(serializer.Serialize(stateList[i]));
                    serializedList.Append("|");
                }
                i++;
            }
            dockState = serializedList.ToString();
            try
            {
                usp_SelectWidgetsPersonalizedResult WP = new usp_SelectWidgetsPersonalizedResult();
                WP.EmpNo = intEmpNo;
                if (NewWidgetID != null)
                {
                    WP.WidgetsID = NewWidgetID;
                }
                WP.DockString = dockState;
                if (IsDeleted == false)
                {
                    int val = new DashboardDO().InsertWidgetsPersonalized(WP);
                    if (val == 1)
                    {
                        NewWidgetID = null;
                        BindDropDown();
                        ddlWidgets.SelectedValue = "-1";
                    }
                }
            }
            catch
            {
            }        
        }
      
        protected void dlDashBoard_LoadDockLayout(object sender, DockLayoutEventArgs e)
        {
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            //Get saved state string from the database - set it to dockState variable for example 
            string dockState = "";
            try
            {
                List<usp_SelectWidgetsPersonalizedResult> WPList = new DashboardDO().SelectWidgetsPersonalized(intEmpNo, null);
                if (WPList.Count > 0)
                {
                    dockState = WPList[0].DockString;
                }
            }
            catch
            {
            }
      
            string[] currentDockStates = dockState.Split('|');
            foreach (string stringState in currentDockStates)
            {
                if (stringState.Trim() != string.Empty)
                {
                    DockState state = serializer.Deserialize<DockState>(stringState);
                    e.Positions[state.UniqueName] = state.DockZoneID;
                    e.Indices[state.UniqueName] = state.Index;
                }
            }
        }
        protected void lnkBtnPersonalizePage_Click(object sender, EventArgs e)
        {
            SetDockZoneStyle(false, Color.Gray, BorderStyle.Dashed);
        }
        protected void lnkBtnClose_Click(object sender, EventArgs e)
        {
            SetDockZoneStyle(true, Color.Gray, BorderStyle.None);
        }
        private void SetDockZoneStyle(bool IsVisible, Color dzBorderColor, BorderStyle dzBorderStyle)
        {
            if (IsVisible == false)
            {
                lnkBtnPersonalizePage.Visible = false;
                pnlAddWidgets.Visible = true;
                if (dlDashBoard.GetRegisteredDocksState().Count > 0)
                {
                    int i = 0;
                    while (i < dlDashBoard.GetRegisteredDocksState().Count)
                    {
                        if (dlDashBoard.RegisteredDocks[i].Commands.Count == 0)
                        {
                            dlDashBoard.RegisteredDocks[i].Command += new DockCommandEventHandler(dock_Command);
                            dlDashBoard.RegisteredDocks[i].Commands.Add(new DockCloseCommand());
                            dlDashBoard.RegisteredDocks[i].Commands.Add(new DockExpandCollapseCommand());
                        }
                        dlDashBoard.RegisteredDocks[i].Pinned = false;                    
                        i++;
                    }
                }
            }
            else
            {
                lnkBtnPersonalizePage.Visible = true;
                pnlAddWidgets.Visible = false;
                if (dlDashBoard.GetRegisteredDocksState().Count > 0)
                {
                    int i = 0;
                    //dlDashBoard.RegisteredDocks[i].Commands.RemoveAt(0);
                    //dlDashBoard.RegisteredDocks[i].Commands.RemoveAt(0);
                    while (i < dlDashBoard.GetRegisteredDocksState().Count)
                    {
                        int k = dlDashBoard.RegisteredDocks[i].Commands.Count - 1;
                        //for (int j = k; j >= 0; j--)
                        //{
                        dlDashBoard.RegisteredDocks[i].Commands.RemoveAt(0);
                        // dlDashBoard.RegisteredDocks[i].Commands.RemoveAt(0);
                        //}
                        //dlDashBoard.RegisteredDocks[i].Commands.RemoveAt(0);
                        if (dlDashBoard.RegisteredDocks[i].Commands.Count > 0)
                        {
                            //    dlDashBoard.RegisteredDocks[i].Commands.RemoveAt(0);
                            //int k = dlDashBoard.RegisteredDocks[i].Commands.Count - 1;
                            //for (int j = k; j >= 0; j--)
                            //{
                            //    dlDashBoard.RegisteredDocks[i].Commands.RemoveAt(j);
                            //}
      
                            //    dlDashBoard.RegisteredDocks[i].Commands.RemoveAll(w => w.Name == "Close");
                            //  dlDashBoard.RegisteredDocks[i].Commands.RemoveAll(w => w.Name == "ExpandCollapse");   
      
                            //dlDashBoard.RegisteredDocks[i].Commands.RemoveRange(0, dlDashBoard.RegisteredDocks[i].Commands.Count);
                            //dlDashBoard.RegisteredDocks[i].Commands.RemoveAt(0);
                            //dlDashBoard.RegisteredDocks[i].Commands.RemoveRange(0, dlDashBoard.RegisteredDocks[i].Commands.Count);
      
                            //int j = 0;
                            //while (j < dlDashBoard.RegisteredDocks[i].Commands.Count)
                            //{
                            //    DockCommand item = new DockCommand();
                            //    item = new DockCloseCommand();
                            //    dlDashBoard.RegisteredDocks[i].Commands.RemoveRange(0,dlDashBoard.RegisteredDocks[i].Commands.Count-1);
                            //    j++;
                            //}
                        }
                        dlDashBoard.RegisteredDocks[i].Pinned = true;
                        i++;
                    }
                }
            }
            dzTop.BorderColor = dzBorderColor;
            dzTop.BorderStyle = dzBorderStyle;
            dzLeft.BorderColor = dzBorderColor;
            dzLeft.BorderStyle = dzBorderStyle;
            dzRight.BorderColor = dzBorderColor;
            dzRight.BorderStyle = dzBorderStyle;
        }
    }


    Thanks,
    Jayesh Goyani
  2. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 20 Apr 2011 Link to this post

    Hi Jayesh,

    I am not quite If I understand the exact problem. If you are using default dock commands. by design, the Commands collection is populated in the PreRender event, and accessing it in the Button click event it will be empty.

    Correct me if I am wrong but I believe you want to modify the commands of the dock to achieve this I would recommend you to use the RadDock's DefaultCommands property to set the required dock commands.

    Kind regards,
    Dobromir
    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.

  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top