Checking information that an item has

Home > Basic examples > Example 06

Explanation

The items that can be added to the component are local files and virtual files.

A local file refers to an item registered using a file dialog, and a virtual file refers to an item representing a virtual file registered using the addVirtualFile and addVirtualFileList functions.

Many manipulation functions are provided in the component to obtain information about the item.

var dx = dx5.get("component-id");

// Returns the number of all items.
var countAll = dx.getTotalItemCount();

// returns the number of local file entries.
var countLocal = dx.getTotalLocalFileCount();

// Returns the number of virtual file entries.
var countVirtual = dx.getTotalVirtualFileCount();

// Returns the number of deleted virtual file entries.
var countRemoved = dx.getTotalRemovedFileCount();

To get detailed information about a particular item, you first need to get the object.

You can use the getItems, getSelectedItems, getItemById, and getItemByIndex functions to retrieve a specific item or array.

var dx = dx5.get("component-id");

// Returning the item corresponding to the given ID or sequence.
var item1 = dx.getItemById("item id");
var item2 = dx.getItemByIndex(3);

// Returning an array of all items.
var allItems = dx.getItems();

// Returning an array of selected items
var selectedItems = dx.getSelectedItems();

// Returning an array of checked items
var checkedItems = dx.getCheckedItems();

An item is a JSON object with the following properties:

Since all returned items are duplicated objects, changing the attribute values ​​of the target object does not affect the internal components.

Example