BoxReorderer Plugin with panels only draggable on header

Page 1 of 2 12 LastLast
  1. #1

    BoxReorderer Plugin with panels only draggable on header

    Hi,

    I use the BoxReorderer Plugin to reorder panels inside a container. Reordering works well, but my panels inside the container contains textfields as well, and because of the BoxReorderer plugin it's very hard to focus on a textfield. Is there a possibility to make only the header dragable so I can focus on the textfields without problem?

    <ext:Container ID="Container" runat="server">
    	<LayoutConfig>
    		<ext:VBoxLayoutConfig Align="Stretch" DefaultMargins="2" />
    	</LayoutConfig>
    	<Plugins>
    		<ext:BoxReorderer runat="server" />
    	</Plugins>
    	<Items>
    		<ext:Panel runat="server" Layout="Anchor" BodyPaddingSummary="5" BodyStyle="border:0" Border="false" Title="Panel">
    			<Items>
    				<ext:TextField runat="server" />
    				<ext:TextArea runat="server" />
    			</Items>
    		</ext:Panel>
    		<ext:Panel runat="server" Layout="Anchor" BodyPaddingSummary="5" BodyStyle="border:0" Border="false" Title="Panel">
    			<Items>
    				<ext:TextField runat="server" />
    				<ext:TextArea runat="server" />
    			</Items>
    		</ext:Panel>
    		<ext:Panel runat="server" Layout="Anchor" BodyPaddingSummary="5" BodyStyle="border:0" Border="false" Title="Panel">
    			<Items>
    				<ext:TextField runat="server" />
    				<ext:TextArea runat="server" />
    			</Items>
    		</ext:Panel>
    	</Items>
    </ext:Container>
  2. #2
    Hello!

    Try the following:

    <ext:BoxReorderer ID="BoxReorderer1" runat="server" ItemSelector=".x-panel-header" />
  3. #3
    Hi,

    it would be exactly what I need, I took the x-toolbar as ItemSelector. Unfortunately the reordering is not working correctly now.. I'm able to move around the panel but if I move for example the last panel of three to the second position inside the container it doesn't rearrange the other panels and moving is no longer possible.. Any idea?

    Thanks
  4. #4
    Needs to override something in BoxReorderer.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    
        <script>
            Ext.ux.BoxReorderer.override({
                getNewIndex: function(pointerPos) {
                    var me = this,
                        dragEl = me.getDragEl(),
                        dragBox = Ext.fly(dragEl).getPageBox(),
                        targetEl,
                        targetBox,
                        targetMidpoint,
                        i = 0,
                        it = me.container.items.items,
                        ln = it.length,
                        lastPos = me.lastPos;
    
                    me.lastPos = dragBox[me.startAttr];
    
                    for (; i < ln; i++) {
                        targetEl = it[i].getEl();
    
                        // Only look for a drop point if this found item is an item according to our selector
                        if (targetEl.is(me.reorderer.itemSelector) || targetEl.down(me.reorderer.itemSelector)) { // overridden
                            targetBox = targetEl.getPageBox();
                            targetMidpoint = targetBox[me.startAttr] + (targetBox[me.dim] >> 1);
                            if (i < me.curIndex) {
                                if ((dragBox[me.startAttr] < lastPos) && (dragBox[me.startAttr] < (targetMidpoint - 5))) {
                                    return i;
                                }
                            } else if (i > me.curIndex) {
                                if ((dragBox[me.startAttr] > lastPos) && (dragBox[me.endAttr] > (targetMidpoint + 5))) {
                                    return i;
                                }
                            }
                        }
                    }
                }
            })
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:Container runat="server">
                <LayoutConfig>
                    <ext:VBoxLayoutConfig Align="Stretch" DefaultMargins="2" />
                </LayoutConfig>
                <Plugins>
                    <ext:BoxReorderer runat="server" ItemSelector=".x-panel-header" />
                </Plugins>
                <Items>
                    <ext:Panel runat="server" Title="Panel 1">
                        <Items>
                            <ext:TextField runat="server" />
                            <ext:TextArea runat="server" />
                        </Items>
                    </ext:Panel>
                    <ext:Panel runat="server" Title="Panel 2">
                        <Items>
                            <ext:TextField runat="server" />
                            <ext:TextArea runat="server" />
                        </Items>
                    </ext:Panel>
                    <ext:Panel runat="server" Title="Panel 3">
                        <Items>
                            <ext:TextField runat="server" />
                            <ext:TextArea runat="server" />
                        </Items>
                    </ext:Panel>
                </Items>
            </ext:Container>
        </form>
    </body>
    </html>
  5. #5
    It throw an error in endDrag because me.dragCmp.lastBox is null...

    me.dragCmp.lastBox[layout.names.x]=me.dragCmp.getPosition(true)[layout.names.widthIndex];
  6. #6
    I was wrong. The Ext.ux.BoxReorderer is undefined when I try to override it. I tried it on my User Control in the script tag to override but at this time Ext.ux.BoxReorderer is not available!! Any ideas?
  7. #7
    Provide a test case, please.
  8. #8
    Well, things are a bit complicated.. So, we have a master page where the ResourceManager is defined. On this master page we include some js-scripts with the asp:ScriptManager.. One of the files we include there is Ext.override.js which includes the override for Ext.ux.BoxReorderer..
    Next we have a aspx page which includes several ascx files.. One of them is loading dynamically the ascx file which uses the BoxReorderer plugin..

    So, it looks like the Ext.ux.BoxReorderer is not defined at the moment we try to override it..

    Is there a way to make sure the component Ext.ux.BoxReorderer is loaded?

    Thanks
    Marco
  9. #9
    Quote Originally Posted by Willimaendu View Post
    On this master page we include some js-scripts with the asp:ScriptManager.
    Please demonstrate how you do that.

    Generally speaking, just putting the override into a page's head should work.
  10. #10
    Ok, our master page looks like that (simplified):

    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="Test.Web.Site" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width" />
        <title><%: Resources.Site.SiteTitle %> - <%: Page.Title %></title>
        <link href="~/Styles/Site.css" rel="stylesheet" />
        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager ID="ExtResourceManager" runat="server" HideInDesign="true">
                <Listeners>
                    <BeforeAjaxRequest Handler="#{maskDiv}.removeCls('x-hide-display');" />
                    <AjaxRequestComplete Handler="#{maskDiv}.addCls('x-hide-display');" />
                    <AjaxRequestException Handler="#{maskDiv}.addCls('x-hide-display');" />
                </Listeners>
            </ext:ResourceManager>
            <asp:ScriptManager ID="aspScriptManager" runat="server" EnableScriptLocalization="true">
                <Scripts>
                    <asp:ScriptReference Path="~/Scripts/StringResources.js" />
                    <asp:ScriptReference Path="~/Scripts/Site.js" />
                    <asp:ScriptReference Path="~/Scripts/Ext.override.js" />
                </Scripts>
            </asp:ScriptManager>
            <ext:Viewport ID="SiteLayout" runat="server" Layout="BorderLayout">
                <Items>
                    <ext:Panel ID="NorthPanel" runat="server" Region="North" BaseCls="header">
                        <Content>
                            <table cellpadding="0" cellspacing="0" width="100%">
                                <tr>
                                    <td>
                                        <asp:HyperLink runat="server" CssClass="site-title" NavigateUrl="~/" Text="<%$ Resources:Site, SiteTitle %>" />
                                        <asp:Label runat="server" ID="lblEnvironment" CssClass="environment" Visible="false" />
                                    </td>
                                    <td>
                                        <asp:LoginView runat="server">
                                            <LoggedInTemplate>
                                                <uc:UserFunctions ID="UserFunctions" runat="server" />
                                            </LoggedInTemplate>
                                        </asp:LoginView>
                                    </td>
                                </tr>
                            </table>
                        </Content>
                    </ext:Panel>
                </Items>
            </ext:Viewport>
        </form>
    </body>
    </html>
    Our Ext.override.js looks like that:

    /**
    Fix for HtmlEditor in IE. Inserts <br /> tag instead of <p></p> tags on pressing 'Enter' key.
    http://forums.ext.net/showthread.php?17095-CLOSED-Problem-with-%E2%80%9CHtmlEditor%E2%80%9D-component-in-IE
    */
    Ext.form.HtmlEditor.override({
        fixKeys: function () {
            if (Ext.isIE) {
                return function (e) {
                    var me = this,
    					key = e.getKey(),
    					doc = me.getDoc();
                    if (key == e.ENTER) {
                        var range = doc.selection.createRange();
                        if (range) {
                            var target = range.parentElement();
                            if (!target || target.tagName.toLowerCase() != 'li') {
                                e.stopEvent();
                                range.pasteHTML('<br />');
                                range.collapse(false);
                                range.select();
                            }
                        }
                    }
                };
            }
        }()
    });
    
    Ext.ux.BoxReorderer.override({
    	getNewIndex: function(pointerPos) {
    		var me = this,
    			dragEl = me.getDragEl(),
    			dragBox = Ext.fly(dragEl).getPageBox(),
    			targetEl,
    			targetBox,
    			targetMidpoint,
    			i = 0,
    			it = me.container.items.items,
    			ln = it.length,
    			lastPos = me.lastPos;
    
    		me.lastPos = dragBox[me.startAttr];
    
    		for (; i < ln; i++) {
    			targetEl = it[i].getEl();
    
    			// Only look for a drop point if this found item is an item according to our selector
    			if (targetEl.is(me.reorderer.itemSelector) || targetEl.down(me.reorderer.itemSelector)) { // overridden
    				targetBox = targetEl.getPageBox();
    				targetMidpoint = targetBox[me.startAttr] + (targetBox[me.dim] >> 1);
    				if (i < me.curIndex) {
    					if ((dragBox[me.startAttr] < lastPos) && (dragBox[me.startAttr] < (targetMidpoint - 5))) {
    						return i;
    					}
    				} else if (i > me.curIndex) {
    					if ((dragBox[me.startAttr] > lastPos) && (dragBox[me.endAttr] > (targetMidpoint + 5))) {
    						return i;
    					}
    				}
    			}
    		}
    	}
    });
    If I include the override in this Javascript file it seems that Ext.ux.BoxReorderer is not loaded at this time..



    Our page:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Overview.aspx.cs" Inherits="Test.Web.BV.Overview" Title="<%$ Resources:Pages, VOverview %>" %>
    
    
    <asp:Content ContentPlaceHolderID="MainContent" runat="server">
    	
    	<script type="text/javascript">
    		var showVContextMenu = function (record, contextMenu, pos) {
    			var vType = "<%= typeof(v).FullName %>";
    
    		if (record.raw.Type == vType) {
    			contextMenu.showAt(pos);
    			return true;
    		} else {
    			return false;
    		}
    	};
    </script>
    
        <ext:Container runat="server">
            <LayoutConfig>
                <ext:HBoxLayoutConfig Align="Stretch" />
            </LayoutConfig>
            <Items>
                <ext:Container runat="server" Width="400" Layout="VBoxLayout">
                    <LayoutConfig>
                        <ext:VBoxLayoutConfig Align="Stretch" />
                    </LayoutConfig>
                    <Items>
                        <ext:FormPanel ID="FilterFormPanel" runat="server" Cls="filter-panel" BodyCls="filter-body">
                            <Items>
    							<ext:FieldContainer runat="server" AnchorHorizontal="100%" Layout="HBoxLayout">
    								<FieldDefaults LabelAlign="Top" />
    								<Items>
    									..................
    								</Items>
    							</ext:FieldContainer>
    								..................
    							</ext:FieldContainer>
                            </Items>
                        </ext:FormPanel>
    					
                        <ext:TreePanel ID="VTreePanel" ClientIDMode="Static" runat="server" RootVisible="False" Animate="False" AutoScroll="True" Flex="1" Cls="tree-panel">
                            <TopBar>
                                <ext:Toolbar runat="server">
                                    <Items>
                                        <ext:Label runat="server" Cls="toolbar-title" Text="<%$ Resources:V, VUebersicht %>" />
                                    </Items>
                                </ext:Toolbar>
                            </TopBar>
    						<Fields>
    							..................
    						</Fields>
    						<ColumnModel>
    							<Columns>
    								..................
    							</Columns>    
    						</ColumnModel>
                            <View>
                                <ext:TreeView runat="server" ToggleOnDblClick="false" />
                            </View>
                            <SelectionModel>
                                <ext:TreeSelectionModel runat="server" ID="VTreePanelSelectionModel" SingleSelect="true" />
                            </SelectionModel>
                        </ext:TreePanel>
                    </Items>
                </ext:Container>
                <ext:BoxSplitter runat="server" Collapsible="False" Cls="details-splitter" />
                <ext:Container runat="server" ID="DetailsContainer" Flex="1" Layout="Fit">
                    <Content>
    	                <ext:Container runat="server" AutoScroll="true">
    						<LayoutConfig>
    							<ext:VBoxLayoutConfig Align="Stretch" />
    						</LayoutConfig>
    		                <Content>
    							<uc:VContainer ID="VContainerUserControl" runat="server" OnVSaved="VContainerUserControl_VSaved" />
    		                </Content>
    	                </ext:Container>
                    </Content>
                </ext:Container>
    		</Items>
        </ext:Container>
    
    </asp:Content>
    And then in the VContainerUserControl we load another user control which has a container and uses the BoxReorderer plugin.

    If I put the override javascript code in the page head there is an error in the init function of the plugin, following code encounters the error:
    me.animatePolicy[container.getLayout().names.x]=true
    names is undefined..
Page 1 of 2 12 LastLast

Similar Threads

  1. Draggable panels
    By nagamalli in forum 1.x Help
    Replies: 3
    Last Post: Dec 25, 2014, 9:25 AM
  2. [CLOSED] Draggable Panels
    By mohan.bizbites in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 26, 2013, 9:46 AM
  3. Replies: 11
    Last Post: Jul 12, 2013, 6:19 AM
  4. Draggable Panels with portals issue
    By nagamalli in forum 1.x Help
    Replies: 1
    Last Post: May 30, 2013, 10:52 AM
  5. Draggable Accordion Panels Easy?
    By cgountanis in forum 1.x Help
    Replies: 2
    Last Post: Dec 16, 2009, 11:48 AM

Tags for this Thread

Posting Permissions