[ enum ] DataType

Description:

Enum for data types used with drag and drop.
Used with dragDataType(), dropDataType(), and to check if certain data type was dragged onto component.

Type: string

Properties:

Name Description

None

No data.

All

Accept any type. Used only for dropDataType().

Text

Plain text.

HTML

HTML content.

Image

Image data.

FileList

Files from system clipboard or drag.

URIList

List of URIs.

URL

A single URL string.

JSON

JSON-encoded data.

Components

UI components (component/*).

Examples:

Sets the type of data list items represent when dragged:

list.dragDataType(DataType.FileList);

Sets the type of data Table component accepts:

table.dropDataType([DataType.FileList, DataType.URIList, DataType.URL]);

Check if expected data type was dragged onto Label:

label.dropAction(DragDropAction.CopyOrMove).dropDataType(DataType.FileList).onDropEvents(e => {
 if(e.type === "drop" && Array.isArray(e.data[DataType.FileList]))
 {
     // set first file as label's icon image
     e.target.icon(e.data[DataType.FileList][0]);
 }
});