[CLOSED] Declare DragTracker or DropTarget controls

  1. #1

    [CLOSED] Declare DragTracker or DropTarget controls

    Hi,

    Is any way to put DragTracker or DropTarget controls inside an UserControl or a Panel container?

    Thanks.
    Last edited by Daniil; Jul 10, 2012 at 11:15 AM. Reason: [CLOSED]
  2. #2
    Hi,

    I would try to put these things into the control Bin.
    http://forums.ext.net/showthread.php...ll=1#post57259
  3. #3
    Hi,

    I just test this option before...

    If I put all these controls inside a Bin container inside my UserControl, all my page appears in blank. But if I put them in my main view, inside an asp Content control (before Viewport) all page is shown as expected.

    Any idea?
  4. #4
    Well,

    It looks like moving DragTracker and DropTarget controls to Content and keeping Store into the Bin container, it works as expected.

    Thanks.
  5. #5
    Confirm, the DropTarget placed in the Bin collection doesn't currently work. It will be fixed in v2.1. Thanks for the report.

    But DragTracker should work. Here is the example based on:
    https://examples2.ext.net/#/DragDrop...d/DragTracker/

    There are two changes.

    1. The DragTracker has been moved to the Viewport Bin.
    2. It is accessed
    #{Viewport1}.bin[0]
    instead of
    #{DragTracker1}
    within the Panel AfterRender listener.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="System.Collections.Generic"%>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            divsData.Items.Add("divs", new List<object>
            {
                new { X=20,  Y=20 },
                new { X=80,  Y=20 },
                new { X=140, Y=20 },
                new { X=200, Y=20 },
                new { X=20,  Y=80 },
                new { X=80,  Y=80 },
                new { X=140, Y=80 },
                new { X=200, Y=80 },
                new { X=20,  Y=140 },
                new { X=80,  Y=140 },
                new { X=140, Y=140 },
                new { X=200, Y=140 }
            });
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Click and Drag to Select Items - Ext.NET Examples</title>
        
        <style type="text/css">
            div.tracked-item {
                border           : 1px solid silver;
                background-color : #f0f080;
                width            : 40px;
                height           : 40px;
                text-align       : center;
                line-height      : 40px;
                font-size        : 11px;
                font-family      : sans-serif;
                position         : absolute;
                cursor           : default;
            }
            
            .drag-area {
                background-color : #f0f0f0 ! important;
                position         : relative;
            }
            
            .dd-proxy {
                opacity      : 0.4;
                -moz-opacity : 0.4;
                filter       : alpha(opacity=40);
                cursor       : default ! important;
            }
            
            div.tracked-item.selected {
                background-color : blue;
                color            : white;
                font-weight      : bold;
            }
        </style>
        
        <script type="text/javascript">        
            var startTrack = function () {
                Ext.select("div.tracked-item.selected").removeCls("selected");
                this.items = Ext.select("div.tracked-item", true);
            };
            
            var dragTrack = function () {            
                this.items.each(function (item) {
                    var r = item.getRegion(),
                        sel = this.dragRegion.intersect(r);
                    
                    if (sel) {
                        item.addCls("selected");
                    } else {
                        item.removeCls("selected");
                    }
                }, this);
            };
            
            var endTrack = function () {                
                delete this.items;
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:ObjectHolder ID="divsData" runat="server" />
            
            <ext:XTemplate ID="Tpl1" runat="server">
                <Html>
                    <tpl for=".">
                         <div id="item-{#}" index="{#}" class="tracked-item" style="top:{Y}px;left:{X}px;">Item {#}</div>
                    </tpl>
                </Html>
            </ext:XTemplate>
            
            <ext:Viewport ID="Viewport1" runat="server" Layout="Border">
                <Bin>
                    <ext:DragTracker runat="server">
                        <Listeners>
                            <DragStart Fn="startTrack" />
                            <Drag Fn="dragTrack" />
                            <DragEnd Fn="endTrack" />
                        </Listeners>
                    </ext:DragTracker>
                </Bin>
                <Items>
                    <ext:Panel runat="server" Region="North" Height="70">
                        <Content>
                             <h3>Click and Drag to Select Items</h3>
                        </Content>
                    </ext:Panel>
                    <ext:Panel 
                        runat="server" 
                        Region="Center"
                        BodyCssClass="drag-area">
                        <Listeners>
                            <AfterRender Handler="#{Tpl1}.overwrite(this.body, #{divsData}.divs);
                                                  #{Viewport1}.bin[0].initEl(this.el);" />                        
                        </Listeners>
                    </ext:Panel>
                </Items>
            </ext:Viewport>
        </form>    
    </body>
    </html>
    Last edited by Daniil; Jul 09, 2012 at 12:31 PM.
  6. #6
    Yes,

    I tried that, but I prefer to access DragTracker using control's name and not via Bin index, so I prefer to place it into Container instead.

    Thanks.
  7. #7
    We have added the getBinComponent method for the AbstractComponent class. It retrieves a bin component by its index, itemId or id.

    Revision #4188, branch 2.1.

    After update you can use:
    #{Viewport1}.getBinComponent('DragTracker1').initEl(this.el);
    Generally, the #{} syntax should work with the Bin components which are inherited from the AbstractComponent class. But DragTracker, DropTarget, etc. are not inherited from the AbstractComponent class. We will look how to get this working with these classes as well.
  8. #8
    Thanks.

    We will wait to next NuGet package to test it.
  9. #9
    The issues have been fixed in SVN. I am marking the thread as closed.

    Please feel free to update the thread if you will face any related problems.

    Thanks again for the reports.

Similar Threads

  1. how declare property MODEL in ext.net
    By Darkizza in forum 2.x Help
    Replies: 0
    Last Post: May 04, 2012, 2:54 PM
  2. [CLOSED] CheckColumns with DragTracker
    By vrscm in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 16, 2012, 1:26 PM
  3. [CLOSED] [Version 1.2] - Possible Bug in DropTarget
    By drkoh in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Dec 08, 2011, 5:26 PM
  4. [CLOSED] DropTarget or DropZone?
    By capecod in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 21, 2010, 3:44 PM
  5. [CLOSED] [1.0] Portal as a 'universal' droptarget
    By betamax in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 16, 2010, 3:51 PM

Posting Permissions