Jump to content

Simple drag and drop implementation from UniListBox1 to UniListBox2


Recommended Posts

Hello,

1. Initialization:

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
  UniListBox1.JSInterface.JSConfig('ddReorder', [True]);
end;

2. Settings:

procedure TMainForm.UniFormReady(Sender: TObject);
begin
  UniListBox1.JSInterface.JSAssign('dropZone.isTarget', [False]); //Disable reorder...

  UniListBox2.JSInterface.JSCode(
    'Ext.create("Ext.dd.DropTarget", '#1'.getEl(), {'+
    '    ddGroup: '+ UniListBox1.JSName +'.dropZone.ddGroup,'+
    '    notifyDrop: function(source, evt, data) {  '+
    '        if (data.records) {data.records.forEach(function(rec){ajaxRequest('#1', "_drop", {val: rec.data.val}, false)})}'+
    '    },                                         '+
    '    notifyEnter: function() {                  '+
    '                                               '+
    '    }                                          '+
    '});                                            '
  )
end;

3. Usage:

procedure TMainForm.UniListBox2AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName = '_drop' then
  begin
    UniListBox2.Items.Add(UniListBox1.Items[UniListBox1.Items.IndexOf(Params.Values['val'])]);
    UniListBox1.Items.Delete(UniListBox1.Items.IndexOf(Params.Values['val']));
  end;

end;

image.png.b63bf218e2202ed76e67b18d95855441.png

image.png.0cae097f402cb83af61b57ab871bc354.png

  • Thanks 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...