# JavaScript API updates

**URL:** <https://community.datagrok.ai/t/javascript-api-updates/526>\
**Category:** Features\
**Tags:** datagrok, javascript\
**Created:** [March 15, 2021, 3:17pm UTC](https://community.datagrok.ai/t/javascript-api-updates/526 "2021-03-15T15:17:28Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![aydar.akhmetov](https://community.datagrok.ai/user_avatar/community.datagrok.ai/aydar.akhmetov/32/221_2.png) [@aydar.akhmetov](https://community.datagrok.ai/u/aydar.akhmetov)\
**Post date:** [July 30, 2021, 5:53pm UTC](https://community.datagrok.ai/t/javascript-api-updates/526/13 "2021-07-30T17:53:34Z")

</div>

We’ve added support for creating drag-n-drop objects.  
Any object can be made draggable. And any object can be made a receiver of other objects. Some objects have built-in drag-n-drop support, such as table columns.  
In the example, we are making a drag-and-droppable image.

```javascript
let df = DG.DataFrame.fromColumns([
  DG.Column.fromList(DG.TYPE.STRING,
    'Character', ['Alf', 'Kate', 'Willie']),
  DG.Column.fromList(DG.TYPE.INT, 
    'Age', [229, 45, 42]),
  DG.Column.fromList(DG.TYPE.STRING,
    'Actor', ['Paul Fusco', 'Anne Schedeen', 'Max Wright'])
]);

let control = ui.searchInput('', 'Drag column header or image here...');

let grid = DG.Viewer.grid(df);

let image = ui.image(
  'https://datagrok.ai/img/heinlein.jpg',
  200, 200,
  {target: 'https://datagrok.ai', tooltipMsg: 'Drag Heinlein to Input field'}
);

// Allow dragging and dropping objects into the search field:
ui.makeDroppable(control.input, {
  acceptDrop: (o) => true, // Allow to drag anything into the field
  doDrop: (o, _) => { // Let's check what fell into the input field
    if (o instanceof DG.Column)
      control.value = o.name.toUpperCase() + ' was dropped';
    else if (o instanceof HTMLDivElement)
      control.value = o.style.backgroundImage;
  }
});

// Let's grab and drag the object (image):
ui.makeDraggable(image, {
  getDragObject: () => image, 
  getDragCaption: () => 'You are dragging Heinlein!'
});

ui.dialog()
  .add(control)
  .add(grid)
  .add(image)
  .show();

```

---

_[View the full topic](https://community.datagrok.ai/t/javascript-api-updates/526)._
