[ 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.

Files

Files copied to system clipboard or dragged/dropped.

URIList

List of URIs.

URL

A single URL string.

JSON

JSON-encoded data.

TextEncoding

Text encoding used to encode the Text and/or HTML values.

Components

UI components (component/*).

Examples:

Sets the type of data list items represent when dragged:

list.dragDataType(DataType.Files);

Sets the type of data Table component accepts:

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

Check if expected data type was dragged onto Label:

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