Results 1 to 3 of 3

Thread: Bug Fix - DataView.Draggable - Multi Select

  1. #1

    Default Bug Fix - DataView.Draggable - Multi Select

    I recently encountered a bug in a DataView while trying to select multiple items. The selection was always being replaced with the most recent item. I override the mixin and got it working using the following replacement.

    Code:
    if (!dataview.isSelected(target)) {
        //fix to allow multiple selections if set on the dataview
        selModel.select(dataview.getRecord(target));
    }
    with

    Code:
    if (!dataview.isSelected(target)) {
        //fix to allow multiple selections if set on the dataview
        selModel.select(dataview.getRecord(target), (selModel.getSelectionMode() !== 'SINGLE'));
    }
    Full Override Class:

    Code:
    Ext.define('ModernTactical.Admin.overrides.ux.DataView.Draggable', {
        override: 'Ext.ux.DataView.Draggable',
    
        //overriding mixin's not supported
        getDragData: function(e) {
            var draggable = this.dvDraggable,
                  dataview  = this.dataview,
                  selModel  = dataview.getSelectionModel(),
                  target    = e.getTarget(draggable.itemSelector),
                  selected, dragData;
    
            if (target) {
                // preventDefault is needed here to avoid the browser dragging the image
                // instead of dragging the container like it's supposed to
                e.preventDefault();
    
                if (!dataview.isSelected(target)) {
                       //fix to allow multiple selections if set on the dataview
                       selModel.select(dataview.getRecord(target), (selModel.getSelectionMode() !== 'SINGLE'));
                }
    
                selected = dataview.getSelectedNodes();
                dragData = {
                            copy: true,
                            nodes: selected,
                            records: selModel.getSelection(),
                            item: true
                 };
    
                 if (selected.length === 1) {
                    dragData.single = true;
                    dragData.ddel = target;
                 } else {
                    dragData.multi = true;
                    dragData.ddel = draggable.prepareGhost(selModel.getSelection());
                 }
    
                return dragData;
            }
    
            return false;
    }
    
    });
    Hope this helps someone else. This doesn't fix the bug where selection mode is "SIMPLE" for some reason that auto-deselects always and is not caused by this.

  2. #2
    Ext JS Premium Member
    Join Date
    Nov 2010
    Posts
    26

    Default

    FhyrDrake, thanks for this!

    I can confirm this also works in ExtJS 4.2.3

  3. #3
    Ext JS Premium Member
    Join Date
    Nov 2010
    Posts
    26

    Default

    I take that back - in ExtJS 4.2.3, it looks like the code change for me was to remove the line: `selModel.select(dataview.getRecord(target), (selModel.getSelectionMode() !== 'SINGLE'));`

    With this line, I am getting a "flicker" on a selection. Without this line, the selection seems to occur further up the chain somewhere, so it seems like it is best to not have this code in, though I'm not sure why.

Similar Threads

  1. DataView Modern multi-select?
    By froamer in forum Ext JS 6.x Q&A
    Replies: 5
    Last Post: 9 Nov 2017, 9:05 AM
  2. [OPEN] DataView MULTI selection not working with ux Draggable
    By Lukappa in forum Ext 5: Bugs
    Replies: 2
    Last Post: 17 Mar 2015, 5:56 AM
  3. [CLOSED] DataView with Ext.ux.DataView.Draggable breaks multiselect
    By Drmbolaget in forum Ext:Bugs
    Replies: 5
    Last Post: 10 Sep 2014, 5:01 PM
  4. Dynamically change single select to multi in a dataview
    By yamahaglock in forum Sencha Ext JS Q&A
    Replies: 5
    Last Post: 15 Dec 2011, 9:48 AM
  5. DataView issues when multi-select is false
    By jphillips in forum Sencha Ext JS Q&A
    Replies: 2
    Last Post: 17 Feb 2009, 10:15 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •