2016-12-15 17 views
5

Cách kéo mục bảng điều khiển từ một bảng khác?Cách kéo Name1 Để đặt tên bảng 6

Ví dụ: Tôi muốn kéo bảng Tên1 đến Tên 6. Khi tôi cố gắng bằng cách nhấn shift + mousescrollkey, sau đó nó kéo lỏng mục.

Cảm ơn trước :)

Fiddle: https://fiddle.sencha.com/#fiddle/1hgf&view/editor

Ext.application({ 
    name: 'Fiddle', 

    launch: function() { 
     Ext.define('myColumn', { 
      extend: 'Ext.view.View', 
      xtype: 'mycolumn', 

      padding: 5, 
      margin: 5, 
      style: 'background-color: #f2f2f2;', 

      itemSelector: 'div.nameselector', 
      tpl: ['<tpl for=".">', '<div class="nameselector<tpl if="isTemp"> temp</tpl>">', '{name}', '</div>', '</tpl>'], 

      listeners: { 
       render: function(me) { 
        var tempRec = null; 

        // Create drag zone 
        this.dragZone = new Ext.dd.DragZone(me.getEl(), { 
         // On receipt of a mousedown event, see if it is within a DataView node. 
         // Return a drag data object if so. 
         getDragData: function(e) { 
          // Use the DataView's own itemSelector (a mandatory property) to 
          // test if the mousedown is within one of the DataView's nodes. 
          var sourceEl = e.getTarget(me.itemSelector, 10); 
          // If the mousedown is within a DataView node, clone the node to produce 
          // a ddel element for use by the drag proxy. Also add application data 
          // to the returned data object. 
          if (sourceEl) { 
           d = sourceEl.cloneNode(true); 
           d.id = Ext.id(); 
           return { 
            ddel: d, 
            sourceEl: sourceEl, 
            sourceZone: me, 
            sourceStore: me.store, 
            repairXY: Ext.fly(sourceEl).getXY(), 
            draggedRecord: me.getRecord(sourceEl) 
           } 
          } 
         }, 
         getRepairXY: function() { 
          return this.dragData.repairXY; 
         } 
        }); 

        this.dropZone = new Ext.dd.DropZone(me.getEl(), { 
         // Helper method to return correct class string if drop 
         // is permitted or not. 
         getAllowed: function(allowed) { 
          var proto = Ext.dd.DropZone.prototype; 
          return allowed ? proto.dropAllowed : proto.dropNotAllowed; 
         }, 

         notifyOver: function(source) { 
          return this.getAllowed(source !== me.dragZone); 
         }, 

         // Called when dragged element is over a drop zone. 
         // If allowed, make a copy of the dragged record to 
         // display in the zone (temporarily) by adding the record 
         // to the column store. 
         notifyEnter: function(source, e, data) { 
          var allowed = source !== me.dragZone; 
          if (allowed) { 
           tempRec = data.draggedRecord.clone(); 
           // Set record field 'isTemp' to true which will cause the dataview 
           // template to use the 'temp' style defined in app.css 
           tempRec.set('isTemp', true); 
           me.getStore().add(tempRec); 
          } 
          return this.getAllowed(allowed); 
         }, 

         // Called when the dragged element leaves a container. Remove 
         // the temporary record from the column store, removing the placeholder. 
         notifyOut: function(source, e, data) { 
          if (tempRec) { 
           me.getStore().remove(tempRec); 
          } 
         }, 

         // When a dragged source is over a container, 
         // set the appropriate drop style for the dragged element. 
         onContainerOver: function(source, e, data) { 
          return this.getAllowed(source === me.dragZone); 
         }, 

         // When the element is dropped on a column, check to see 
         // if we are dropping on the same column or not. If not, 
         // then remove record from source column, add record to 
         // drop column. 
         onContainerDrop: function(source, e, data) { 
          var overSame = source == me.dragZone, 
           dragData = source.dragData; 

          if (overSame) { 
           // Do not allow drop over same zone 
           // Return false to do a repair. 
           return false; 
          } 

          var rec = dragData.draggedRecord; 
          dragData.sourceStore.remove(rec); 
          me.getStore().add(rec); 

          // Clear temporary record 
          tempRec = null; 

          return true; 
         } 
        }); 
       } 
      } 
     }); 

     Ext.create('Ext.panel.Panel', { 
      renderTo: Ext.getBody(), 
      plugins: 'viewport', 
      scrollable: 'horizontal', 
      layout: { 
       type: 'hbox', 
       align: 'stretch' 
      }, 
      defaults: { 
       'width': 300 
      }, 
      items: [{ 
       xtype: 'mycolumn', 
       store: { 
        fields: ['name'], 
        data: [{ 
         name: 'Name 1' 
        }] 
       } 
      }, { 
       xtype: 'mycolumn', 
       store: { 
        fields: ['name'], 
        data: [{ 
         name: 'Name 2' 
        }] 
       } 
      }, { 
       xtype: 'mycolumn', 
       store: { 
        fields: ['name'], 
        data: [{ 
         name: 'Name 3' 
        }] 
       } 
      }, { 
       xtype: 'mycolumn', 
       store: { 
        fields: ['name'], 
        data: [{ 
         name: 'Name 4' 
        }] 
       } 
      }, { 
       xtype: 'mycolumn', 
       store: { 
        fields: ['name'], 
        data: [{ 
         name: 'Name 5' 
        }] 
       } 
      }, { 
       xtype: 'mycolumn', 
       store: { 
        fields: ['name'], 
        data: [{ 
         name: 'Name 6' 
        }] 
       } 
      }] 
     }) 
    } 
}); 
+0

có thể tự động ghi là giải pháp ?? –

+0

@ Mr.Bruno autoScoll: true cũng không hoạt động –

+0

Tôi đã thử rất nhiều giải pháp mà tôi đã sử dụng và không ai muốn cuộn bảng điều khiển của bạn tự động, +1 cho tôi, chúng tôi sẽ đợi các slutions khác –

Trả lời

3

Đó là một lỗi trong phiên bản ExtJS 6.0.2 cấu hình cuộn trên dragZone không hoạt động. Không phải panel.scrollBy() mà bạn có thể cuộn bảng điều khiển đó.

Tôi nghĩ rằng bạn sẽ phải cập nhật khung của mình.

Khi bạn cập nhật thành 6.2.0.589, chức năng scrollBy sẽ bắt đầu hoạt động. Bạn có thể thêm sự kiện chuột vào mỗi cột và khi bạn kết thúc, di chuyển bảng điều khiển chính.

containermouseover: function (me) { 
    var panel = Ext.first('#myMainPanel'); 
    panel.scrollBy(me.getX() - panel.getWidth()/4, 0, true); 
}, 

Khi bạn cập nhật thành 6.2.0.981 cấu hình scroll trong dragZone sẽ bắt đầu hoạt động.

this.dragZone = new Ext.dd.DragZone(me.getEl(), { 
    ... 
    // this doesn't work in 6.0.2 but works in 6.2.0.981 
    scroll: true 
}); 

fiddle My https://fiddle.sencha.com/#view/editor&fiddle/1qse

Nhưng bây giờ khi bạn giữ một mục và bạn di chuyển vào cột và nó dropZone mà không phải là trong giao diện trước đây, các cột không được đăng ký như một dropZone và bạn có thể không thả mục. Các thông báo sự kiệnOver không được gọi.

Và Tôi nhận được kết quả tương tự khi tôi thử nghiệm với http://examples.sencha.com/extjs/6.2.0/examples/classic/dd/dragdropzones.html

tôi cho rằng đây là một lỗi ExtJS.

Nói chung tôi không nghĩ rằng đó là thiết kế UX tốt khi bạn phải cuộn trong khi sử dụng kéo và thả.

+0

Thực ra tôi đang tạo kanban trong Extjs, trong đó có cuộn ngang. Khi danh sách nhiệm vụ lớn thì chúng ta cần cuộn để xem danh sách đó. Có rất nhiều nhiệm vụ và chúng tôi có thể kéo nhiệm vụ của bất kỳ danh sách nào vào một danh sách khác không có trong chế độ xem. –

+0

@AjayThakur Tôi đã cố gắng google tại sao dropzone không được đăng ký sau khi cuộn và tôi đã tìm thấy một số thông tin có thể có vấn đề khi các vùng được sử dụng trong Ext.view. * Và chia sẻ cùng một phần tử. Nó có thể là giá trị để viết lại nó vào container có khu vực + xem hoặc một cái gì đó như thế. – pagep

Các vấn đề liên quan