Custom filter

Home > Basic examples > Example 18

Explanation

Since version 3.5.0.0, custom filter functions can be used to limit file items.

var dx = dx5.get("component-id");
/**
 * Rejects if the file name exceeds 10 digits excluding the extension name of it.
 * @param file the File(Blob) object
 * @return If true, allow, false if deny.
 */	
function rejectFilesWithLongName(file) {
	if (file.name.length > 10) return false;
	else return true;
}

function onDX5Created(id) {
	var dx = dx5.get(id);
	...
	// Registers the custom filter function.
	dx.setCustomFilter(rejectFilesWithLongName);
}

Example