2016-12-15 6 views
5

किसी अन्य पैनल से पैनल आइटम को कैसे खींचें?नाम 1 को नाम से कैसे खींचें 6 पैनल

उदाहरण के लिए: मैं नाम 1 को नाम 6 पैनल खींचना चाहता हूं। जब मैंने Shift + mousescrollkey दबाकर कोशिश की, तो यह आइटम खींचने से ढीला हो गया।

अग्रिम धन्यवाद :)

फिडल: 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

ऑटोस्कोल एक समाधान हो सकता है ?? –

+0

@ श्री ब्रूनो ऑटोस्कॉल: सच भी काम नहीं कर रहा है –

+0

मैंने कई समाधानों का प्रयास किया है जो मैंने उपयोग किए हैं और कोई भी आपके पैनल को स्वचालित रूप से स्क्रॉल नहीं करना चाहता, मेरे लिए +1, हम अन्य स्ल्यूशन के लिए प्रतीक्षा करेंगे –

उत्तर

3

यह ExtJS संस्करण 6.0.2 में एक बग dragZone पर स्क्रॉल config काम नहीं करता है। न तो panel.scrollBy() करता है जिसके द्वारा आप उस पैनल को स्क्रॉल कर सकते हैं।

मुझे लगता है कि आपको अपना ढांचा अपडेट करना होगा।

जब आप 6.2.0.589 पर अपडेट करते हैं तो scrollBy फ़ंक्शन काम करना शुरू कर देगा। आप प्रत्येक कॉलम में माउस इवेंट जोड़ सकते हैं और जब आप उस पर हों, तो मुख्य पैनल को स्क्रॉल करें।

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

आप 6.2.0.981 को dragZone में scroll config काम शुरू होगा अद्यतन करते हैं।

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 
}); 

मेरे बेला https://fiddle.sencha.com/#view/editor&fiddle/1qse

लेकिन अब जब आप किसी आइटम को पकड़ और आप स्तंभ में स्क्रॉल करें और उसे dropzone जो ध्यान में रखते हुए पहले नहीं था है, स्तंभ एक dropzone के रूप में पंजीकृत नहीं है और आप कर सकते हैं आइटम ड्रॉप नहीं है। घटनाओं को सूचित करें कभी नहीं कहा जाता है।

और जब मैं के साथ http://examples.sencha.com/extjs/6.2.0/examples/classic/dd/dragdropzones.html

मुझे लगता है कि यह एक और ExtJS बग है प्रयोग मैं एक ही परिणाम हो रही है।

आम तौर पर मुझे नहीं लगता कि यह अच्छा यूएक्स डिज़ाइन है जब आपको ड्रैग और ड्रॉप का उपयोग करते समय स्क्रॉल करना होता है।

+0

दरअसल मैं एक्स्टज में कन्नबान बना रहा हूं जिसमें क्षैतिज स्क्रॉल है। जब कार्य सूचियां बड़ी होती हैं तो हमें उन सूचियों को देखने के लिए स्क्रॉल की आवश्यकता होती है। बहुत सारे कार्य हैं और हम किसी भी सूची के किसी अन्य सूची में कार्य खींच सकते हैं जो देखने में नहीं था। –

+0

@AjayThakur मैंने Google पर कोशिश की कि स्क्रॉल के बाद ड्रॉपज़ोन पंजीकृत क्यों नहीं है और मुझे कुछ जानकारी मिली है कि जब Xon का उपयोग Ext.view। * में किया जाता है और उसी तत्व को साझा करता है तो समस्या हो सकती है। यह कंटेनर को फिर से लिखना लायक हो सकता है जिसमें ज़ोन + व्यू या ऐसा कुछ है। – pagep

संबंधित मुद्दे