[CLOSED] Multiselect - Dropped items

  1. #1

    [CLOSED] Multiselect - Dropped items

    Hi, when using either the Append or Insert modes of the demo https://examples1.ext.net/#/Form/MultiSelect/Overview/

    I've noticed that the order of the selected items is reversed in the target listbox. Is it possible to have them added to the target in the same order the items were originally selected?

    Any help would be great.

    Thanks,

    Gav
  2. #2
    I guess it is undesired behaviour
    I fixed it in SVN
    Here the sample with the fix
    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    
    <!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>Overview of MultiSelect - Ext.NET Examples</title>
        
        <ext:ResourcePlaceHolder runat="server" Mode="ScriptFiles" />
        
        <script type="text/javascript">
            Ext.ux.DDView.override({
                onNodeDrop: function (n, dd, e, data) {
                    if (this.fireEvent("beforedrop", this, n, dd, e, data) === false) {
                        return false;
                    }
                    var pt = this.getDropPoint(e, n, dd);
                    var insertAt = (this.appendOnly || (n == this.el.dom)) ? this.store.getCount() : n.viewIndex;
                    if (pt == "below") {
                        insertAt++;
                    }
    
    
                    // Validate if dragging within a DDView
                    if (data.sourceView == this) {
                        // If the first element to be inserted below is the target node, remove it
                        if (pt == "below") {
                            if (data.viewNodes[0] == n) {
                                data.viewNodes.shift();
                            }
                        } else {  // If the last element to be inserted above is the target node, remove it
                            if (data.viewNodes[data.viewNodes.length - 1] == n) {
                                data.viewNodes.pop();
                            }
                        }
    
    
                        // Nothing to drop...
                        if (!data.viewNodes.length) {
                            return false;
                        }
    
    
                        // If we are moving DOWN, then because a store.remove() takes place first,
                        // the insertAt must be decremented.
                        if (insertAt > this.store.indexOf(data.records[0])) {
                            insertAt--;
                        }
                    }
    
    
                    // Dragging from a Tree. Use the Tree's recordFromNode function.
                    if (data.node instanceof Ext.tree.TreeNode) {
                        var r = data.node.getOwnerTree().recordFromNode(data.node);
    
    
                        if (r) {
                            data.records = [r];
                        }
                    }
    
    
                    if (!data.records) {
                        alert("Programming problem. Drag data contained no Records");
    
    
                        return false;
                    }
    
    
                    for (var i = 0; i < data.records.length; i++) {  // HERE IS THE CHANGE
                    // for (var i = data.records.length-1; i >-1 ; i--) {
                        var r = data.records[i];
                        var dup = this.store.getById(r.id);
    
    
                        if (dup && (dd != this.dragZone)) {
                            if (!this.allowDup && !this.allowTrash) {
                                Ext.fly(this.getNode(this.store.indexOf(dup))).frame("red", 1);
                                return true;
                            }
                            var x = new Ext.data.Record();
                            r.id = x.id;
                            delete x;
                        }
                        if (data.copy) {
                            this.store.insert(insertAt++, r.copy());
                        } else {
                            if (data.sourceView) {
                                data.sourceView.isDirtyFlag = true;
                                data.sourceView.store.remove(r);
                            }
                            if (!this.allowTrash) this.store.insert(insertAt++, r);
                        }
                        if (this.sortField) {
                            this.store.sort(this.sortField, this.sortDir);
                        }
                        this.isDirtyFlag = true;
                    }
                    if (this.dragZone) {
                        this.dragZone.cachedTarget = null;
                    }
    
    
                    this.fireEvent("afterdrop", this, n, dd, e, data);
                    
                    return true;
                }
            });
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            
            <ext:MultiSelect runat="server" AppendOnly="true" DragGroup="grp1" Width="300" Height="250" KeepSelectionOnClick="WithCtrlKey">
                <Items>
                    <ext:ListItem Text="Item 1" Value="1" />
                    <ext:ListItem Text="Item 2" Value="2" />
                    <ext:ListItem Text="Item 3" Value="3" />
                    <ext:ListItem Text="Item 4" Value="4" />
                    <ext:ListItem Text="Item 5" Value="5" />
                </Items>
            </ext:MultiSelect>      
            
            <ext:MultiSelect runat="server" AppendOnly="true" DropGroup="grp1" Width="300" Height="250" KeepSelectionOnClick="WithCtrlKey">
                <Items>
                    <ext:ListItem Text="Item 6" Value="6" />
                    <ext:ListItem Text="Item 7" Value="7" />
                    <ext:ListItem Text="Item 8" Value="8" />
                    <ext:ListItem Text="Item 9" Value="9" />
                    <ext:ListItem Text="Item 10" Value="10" />
                </Items>                                            
            </ext:MultiSelect>      
        </form>
    </body>
    </html>
  3. #3
    Thanks, you can mark as closed.
  4. #4
    Hi Vlad, I've noticed that this change has created an additional bug. Do you want me to create a new Thread?
  5. #5
    The thread is related to this one:
    http://forums.ext.net/showthread.php?16001

Similar Threads

  1. MultiSelect doesn't get items
    By javito in forum 1.x Help
    Replies: 1
    Last Post: Jun 01, 2010, 8:04 AM
  2. How to add items to a MultiSelect??
    By javito in forum 1.x Help
    Replies: 1
    Last Post: May 06, 2010, 5:57 PM
  3. [CLOSED] Set the Selected Items in MultiSelect
    By majestic in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 11, 2010, 2:57 AM
  4. [CLOSED] Multiselect Items not showing up...
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 30, 2009, 8:17 AM
  5. Replies: 0
    Last Post: Jun 03, 2009, 5:30 PM

Posting Permissions