Draggable panels

  1. #1

    Draggable panels

    Hi team,
    We are working on Drag and drop panels in a window

    Please go through the following code,
    To give you runnable code we have simplified these pages




    =========windowsample.aspx======================== ==
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WindowSample.aspx.cs" Inherits="ext1._3Appliction.NewFolder1.WindowSample" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Drag Page</title>
    
        <script runat="server">
            protected void btnLoadView_OnEvent(object sender, DirectEventArgs e)
            {
                wndView.AutoScroll = true;
                wndView.LoadContent("../NewFolder1/DesignDrag.aspx", false);
                wndView.Show();
            }
        </script>
    
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Window ID="wndView" runat="server" Hidden="true" CloseAction="Hide" Layout="FitLayout"
            Width="1000" Height="800" AutoScroll="true" Title="Form Details" Frame="true"
            Modal="true" ButtonAlign="Center" Resizable="true">
        </ext:Window>
        <ext:Button ID="btnLoadView" runat="server" Height="100" Width="100" Text="Load">
            <DirectEvents>
                <Click OnEvent="btnLoadView_OnEvent">
                </Click>
            </DirectEvents>
        </ext:Button>
        </form>
    </body>
    </html>
    ====================master page==========================
    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="ext1._3Appliction.NewFolder1.Site1" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
        <asp:ContentPlaceHolder ID="head" runat="server">
        </asp:ContentPlaceHolder>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="extScriptManager" runat="server" />
        <ext:Viewport ID="vpMaster" runat="server">
            <Content>
                <asp:ContentPlaceHolder ID="PageCotent" runat="server">
                </asp:ContentPlaceHolder>
            </Content>
        </ext:Viewport>
        </form>
    </body>
    </html>
    ======================DesignDrag.aspx============= ==================
    <%@ Page Language="C#" MasterPageFile="~/NewFolder1/Site1.Master" AutoEventWireup="true"
        CodeBehind="DesignDrag.aspx.cs" Inherits="ext1._3Appliction.NewFolder1.DesignDrag"
        Title="Untitled Page" %>
    
    <%@ Register Src="~/UserControls/userDesigner.ascx" TagPrefix="ucDesign" TagName="DesignUser" %>
    
    <script runat="server">
           protected override void OnInit(EventArgs e)
            {
                PrepareUserLayout();
            }
            private void PrepareUserLayout()
            {
                int winHeight = 800, winWidth = 700, positionX = 10, positionY = 10, secWidth = 700, secHeight = 550;
                for (int i = 0; i < 2; i++)
                {
                    ext1._3Appliction.UserControls.userDesigner userEv = (ext1._3Appliction.UserControls.userDesigner)this.LoadControl("~/UserControls/userDesigner.ascx");
                    userEv.ID = "userAdd_" + i;
                    Ext.Net.Panel pnlSection = new Ext.Net.Panel();
                    pnlSection.ID = "sectionPanel_" + i;
                    pnlSection.ContentContainer.Controls.Add(userEv);
                    pnlSection.Header = true;
                    pnlSection.Collapsible = true;
                    pnlSection.Icon = Ext.Net.Icon.Package;
                    pnlSection.Title = "Panel_" + i;
                    pnlSection.Border = true;
                    pnlSection.ForceLayout = true;
                    pnlSection.AutoScroll = true;
                    pnlSection.Cls = "SectionPanel";
                    pnlSection.Height = secHeight;
                    pnlSection.Width = winWidth - 100;
                    pnlSection.X = 20;
                    pnlSection.Y = positionY;
                    positionY += secHeight + 20;
    
                    pnlSection.Draggable = true;
                    pnlSection.Floating = true;
                    pnlSection.DraggableConfig.OnDrag.Fn = "onDrag";
                    pnlSection.DraggableConfig.EndDrag.Fn = "endDrag";
                    pnlSection.AddTo(pnlFormViewer);
    
                    //to resize the panel
                    Ext.Net.Resizable resizable = new Ext.Net.Resizable();
                    resizable.ID = "resizable_" + i;
                    resizable.Element = "={" + pnlSection.ClientID + ".el}";
                    resizable.Transparent = true;
                    resizable.EnabledResizing = true;
                    resizable.Handles = ResizeHandle.All;
                    resizable.Listeners.Resize.Handler = "var p = " + pnlSection.ClientID + "; p.el.setStyle({width:'', height:''});p.setSize(width, height);p.doLayout();";
                    resizable.Render();
                }
            }   
        </script>
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
        <style type="text/css">
            .SectionPanel
            {
                z-index: 11;
            }
        </style>
        <script type="text/javascript">
            var onDrag = function(e) {
                var pel = this.proxy.getEl();
                this.x = pel.getLeft(true);
                this.y = pel.getTop(true);
    
                var s = this.panel.getEl().shadow;
    
                if (s) {
                    s.realign(this.x, this.y, pel.getWidth(), pel.getHeight());
                }
            };
            var endDrag = function(e) {
                this.panel.setPosition(this.x, this.y);
            };
        </script>  
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="PageCotent" runat="server">
        <ext:BorderLayout ID="blFormViewer" runat="server">
            <Center>
                <ext:Panel ID="pnlFormViewer" runat="server" AutoScroll="true" Border="false" BodyBorder="false"
                    StyleSpec="padding:3px;background-color:white;" BodyStyle="padding-right:10px;"
                    ButtonAlign="Right">
                </ext:Panel>
            </Center>
        </ext:BorderLayout>
    </asp:Content>
    =======================UserControl================ ===============
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="userDesigner.ascx.cs"
        Inherits="ext1._3Appliction.UserControls.userDesigner" %>
    <ext:BorderLayout ID="clSectionEvaluator" runat="server" Margin="100">
        <Items>
            <ext:Panel ID="pnlColumn1" runat="server" Region="Center" Height="200" Frame="false"
                Border="false">
                <Items>
                    <ext:TextArea ID="txtAddress" runat="server" Width="300" Height="100" FieldLabel="Address">
                    </ext:TextArea>
      	    </Items>
            </ext:Panel>
        </Items>
    </ext:BorderLayout>

    issue is as follows
    Run the code--> click on load button
    scroll to end in window and try to drag the second panel to its left or right,
    When we are dragging it, the panel is not placed in the desired position(it is moving to top),
    How can we solve this problem?
    And how can we stop shadow and dotted lines of the panel while dragging(see the attached screenshots)

    Please contact if you need more explanation
    Thank you
    Nagamalli.
    Attached Thumbnails Click image for larger version. 

Name:	BeforeDrag.png 
Views:	14 
Size:	84.9 KB 
ID:	6791   Click image for larger version. 

Name:	OnDragging.png 
Views:	15 
Size:	83.4 KB 
ID:	6792  
  2. #2
    Hi @nagamalli,

    Being dragged a component's DOM is removed from the current container. AutoScroll catches it and "decide" no more scrolling needs. So, a dragged component jumps to the top. I can suggest some changes in layout to get it working. Also some change in the onDrag function is required to get it working with scrolling.

    To remove a dotted square, please add this for the DraggableConfig.
    <CustomConfig>
        <ext:ConfigItem Name="insertProxy" Value="false" Mode="Raw" />
    </CustomConfig>
    Also I guess you won't need to remove shadows since it will be aligned correctly now.

    Master Page
    <%@ Master Language="C#" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Master</title>
        <asp:ContentPlaceHolder ID="head" runat="server" />
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:Viewport runat="server" AutoScroll="true">
                <Content>
                    <asp:ContentPlaceHolder ID="PageContent" runat="server" />
                </Content>
            </ext:Viewport>
        </form>
    </body>
    </html>
    Content Page
    <%@ Page Language="C#" MasterPageFile="~/Site1.Master" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected override void OnInit(EventArgs e)
        {
            PrepareUserLayout();
        }
        
        private void PrepareUserLayout()
        {
            int secHeight = 550,
                winWidth = 700,
                positionY = 10;
            
            for (int i = 0; i < 2; i++)
            {
                UserControl userEv = (UserControl)this.LoadControl("TestUC.ascx");
                userEv.ID = "userAdd_" + i;
                
                Ext.Net.Panel pnlSection = new Ext.Net.Panel();
                pnlSection.ID = "sectionPanel_" + i;
                pnlSection.ContentControls.Add(userEv);
                pnlSection.Floating = true;
                pnlSection.Title = "Panel_" + i;
                pnlSection.Height = secHeight;
                pnlSection.Width = winWidth - 100;
                pnlSection.X = 20;
                pnlSection.Y = positionY;
                positionY += secHeight + 20;
                
                pnlSection.DraggableConfig.OnDrag.Fn = "onDrag";
                pnlSection.DraggableConfig.EndDrag.Fn = "endDrag";
                pnlSection.DraggableConfig.CustomConfig.Add(new ConfigItem() { Name = "insertProxy", Value = "false", Mode = ParameterMode.Raw });
                Panel1.Items.Add(pnlSection);
            }
        }   
    </script>
    <asp:Content ContentPlaceHolderID="head" runat="server">
        <script type="text/javascript">
            var onDrag = function (e) {
                var pel = this.proxy.getEl();
                this.x = pel.getLeft(true);
                this.y = pel.getTop(true) + this.panel.ownerCt.ownerCt.el.dom.scrollTop; // take scrollTop into account
    
                var s = this.panel.getEl().shadow;
    
                if (s) {
                    s.realign(this.x, this.y, pel.getWidth(), pel.getHeight());
                }
            };
    
            var endDrag = function (e) {
                this.panel.setPosition(this.x, this.y);
            };
        </script>
    </asp:Content>
    
    <asp:Content ContentPlaceHolderID="PageContent" runat="server">
        <ext:ContainerLayout runat="server">
            <Items>
                <ext:Panel ID="Panel1" runat="server" Height="1200" />
            </Items>
        </ext:ContainerLayout>
    </asp:Content>
    Last edited by Daniil; Dec 22, 2014 at 3:36 PM.
  3. #3

    Same thing not working with EXT Net 3.0 Dll

    Hi Danill,
    The above post is posted by our team last year when we are working with EXT Net 1. DLL,
    Here we moved our application to the 3.0 Dll so here we are facing several problems with the existing code,

    I am listing some of the issues which are are underlined below

    1)
     pnlSection.DraggableConfig.EndDrag.Fn = "endDrag";
    //Ext 3.0 is not Supporting EndDrag

    2)
      pnlSection.DraggableConfig.CustomConfig.Add(new ConfigItem() { Name = "insertProxy", Value = "false", Mode = ParameterMode.Raw });
    3)
      Ext.Net.Resizable resizable = new Ext.Net.Resizable();
    //Resizable is not supporting with 3.0

    4)
      resizable.Element = "={" + pnlSection.ClientID + ".el}";
    //Resizable is not supporting with 3.0

    could you please find me the solution

    Regards
    A.Shrujan
    Last edited by mohan.bizbites; Dec 18, 2014 at 10:31 AM.
  4. #4
    Hi @mohan.bizbites,

    1. I would try onEnd instead of EndDrag.

    2. Please try to remove the "insertProxy" ConfigItem. I doubt it is still required.

    3-4. Resizable. Please see the breaking change item #98 for Ext.NET v2.
    https://examples2.ext.net/#/Getting_...EAKING_CHANGES

    98. The server Resizable class has been renamed to Resizer.

    Its Draggable property has been removed.
    For dragging functionality use the common drag&drop components.

Similar Threads

  1. Replies: 11
    Last Post: Jul 12, 2013, 6:19 AM
  2. Draggable Panels with portals issue
    By nagamalli in forum 1.x Help
    Replies: 1
    Last Post: May 30, 2013, 10:52 AM
  3. [CLOSED] So many panels and nested panels
    By thchuong in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 03, 2012, 5:23 AM
  4. Draggable Accordion Panels Easy?
    By cgountanis in forum 1.x Help
    Replies: 2
    Last Post: Dec 16, 2009, 11:48 AM
  5. Draggable Fieldsets?
    By jlertle in forum 1.x Help
    Replies: 0
    Last Post: Jul 02, 2008, 11:18 PM

Tags for this Thread

Posting Permissions