Jump to content

Drag and Drop UniTreeNode


mos

Recommended Posts

Hi,

 

Try this solution:

 

For example:

 

1. UniTreeView1 -> ClientEvents -> UniEvents -> function beforeInit:

function beforeInit(sender, config)
{
    config.viewConfig = {
        plugins: {
            ptype: 'treeviewdragdrop',
            ddGroup: 'tree2panel',
            appendOnly: true
        },
        listeners: {
            beforedrop: function(node, data, overModel, dropPos, opts) {
                
            },
            drop: function(node, data, overModel, dropPos, opts) {
                
            }

        }
    };
}

2. UniPanel1 -> ClientEvents -> ExtEvents -> function afterrender:

function afterrender(sender, eOpts)
{
    var me = sender;
    me.dropTarget = Ext.create('Ext.dd.DropTarget', me.getEl(), {
        ddGroup: 'tree2panel',
        notifyDrop: function(source, evt, data) {
            //data.records[0].data.text
            //ajaxRequest(me, ....) 
            me.update(data.records[0].data.text);
        },
        notifyEnter: function() {
            
        }
    });
}

Result:

 

post-906-0-09532100-1507912093_thumb.png

 

Best regards,

Link to comment
Share on other sites

Hi,

 

  I have another question:

  • when the drop occurs how can I call a Delphi procedure so I can process the information that was dragged to the panel?

 

1. UniPanel1 -> ClientEvents -> ExtEvents -> function afterrender:

function afterrender(sender, eOpts)
{
    var me = sender;
    me.dropTarget = Ext.create('Ext.dd.DropTarget', me.getEl(), {
        ddGroup: 'tree2panel',
        notifyDrop: function(source, evt, data) {
            //data.records[0].data.text
            ajaxRequest(me, 'dropped', ['id='+data.records[0].data.id, 'text='+data.records[0].data.text]);
            //me.update(data.records[0].data.text);
        },
        notifyEnter: function() {
            
        }
    });
}

2. UniPanel1 -> OnAjaxEvent:

procedure TMainForm.UniPanel1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = 'dropped' then
  begin
    //ShowMessage(Params.Values['id'] + ', ' + Params.Values['text']);
    (Sender as TUniPanel).Caption := Params.Values['text'];
  end;

end;

And tell me what parameters you need also...

 

Best regards,

Link to comment
Share on other sites

Hi Delphi Developer,

 

  Thanks for code again which work just fine however I have one issue which I am trying to get around.

 

  On the treeview I have an onChange event and what I am finding is that when I click and hold down the mouse to start drag the onChange will trigger as well.

 

   Do you know of a way I can avoid the onChange being triggered when I try and start a drag?

Link to comment
Share on other sites

  • 10 months later...
  • 1 year later...
  • 3 years later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...