1. #1
    Sencha User
    Join Date
    Dec 2011
    Posts
    3
    Vote Rating
    0
    randomuser is on a distinguished road

      0  

    Default Unanswered: Drag and Drop - Dataview to GridPanel

    Unanswered: Drag and Drop - Dataview to GridPanel


    I'm trying out drag & drop from dataview to grid panel... following is the code which is used. Drag part alone works fine, i.e, the items form the dataview can be dragged. While dropping it doesnt get dropped.

    Code:
    var dataview = Ext.create('Ext.view.View', {
            deferInitialRefresh: false,
            store: store,
            tpl  : Ext.create('Ext.XTemplate',
                '<tpl for=".">',
                    '<div class="phone">',
                        (!Ext.isIE6? '<img width="64" height="64" src="ext-4.0.7-gpl/examples/view/images/phones/{[values.name.replace(/ /g, "-")]}.png" />' :
                         '<div style="width:74px;height:74px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'images/phones/{[values.name.replace(/ /g, "-")]}.png\',sizingMethod=\'scale\')"></div>'),
                        '<strong>{name}</strong>',
                        '<span>{price:usMoney} ({reviews} Review{[values.reviews == 1 ? "" : "s"]})</span>',
                    '</div>',
                '</tpl>'
            ),
            plugins : [
                Ext.create('Ext.ux.DataView.Animated', {
                    duration  : 550,
                    idProperty: 'id'
                })
            ],
            id: 'phones',
           itemSelector: 'div.phone',
            overItemCls : 'phone-hover',
            singleSelect: true,
            autoScroll  : true,
        });
    
    dataview.on('render', function(v) {
        dataview.dragZone = new Ext.dd.DragZone(v.getEl(), {
            getDragData: function(e) {
            var sourceEl = e.getTarget(v.itemSelector, 10);
             if (sourceEl) {
                    d = sourceEl.cloneNode(true);
                    d.id = Ext.id();
                    return {
                        ddel: d,
                        sourceEl: sourceEl,
                        repairXY: Ext.fly(sourceEl).getXY(),
                        sourceStore: v.store,
                        draggedRecord: v.getRecord(sourceEl)
                    }
                }
            },
            getRepairXY: function() {
                return this.dragData.repairXY;
            }
        });
    });
    --------------------------------------------------------------------------------------------
    
    var Grid = Ext.create('Ext.grid.Panel', {
            title: 'Cart',
            region: 'center',
            margins: '0 5 5 0',
            columns: [{
             width: 215
            },],
           store: store
        });
    
    Grid.on('render', function() {
        Grid.dropZone = new Ext.dd.DropZone(Grid.getView().scroller, {
    
    
            getTargetFromEvent: function(e) {
                   return e.getTarget(Grid.getView().rowSelector);
            },
    
    
            // On entry into a target node, highlight that node.
            onNodeEnter : function(target, dd, e, data){ 
            
                Ext.fly(target).addCls('my-row-highlight-class');
            },
    
    
            onNodeOut : function(target, dd, e, data){ 
                Ext.fly(target).removeCls('my-row-highlight-class');
            },
    
    
             onNodeOver : function(target, dd, e, data){ 
                return Ext.dd.DropZone.prototype.dropAllowed;
            },
    
    
            onNodeDrop : function(target, dd, e, data){
                var rowIndex = Grid.getView().findRowIndex(target);
                var r = Grid.getStore().getAt(rowIndex);
                Ext.Msg.alert('Drop gesture', 'Dropped Record id ' + data.draggedRecord.id +
                    ' on Record id ' + r.id);
                return true;
            }
        });
    });
    Last edited by mitchellsimoens; 13 Mar 2012 at 10:25 AM. Reason: added [CODE] tags

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,782
    Answers
    3465
    Vote Rating
    833
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Should you be creating the drop zone on the scroller or the getView()?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi