Skip to main content

Clusters class

📖 Description​

The Clusters class represents a collection of clusters (sections) in a form definition. Each cluster in the collection is a Cluster instance.

🗃️ Fields​


🏷️ all​

Retrieves all the clusters that are in the collection.

Type​

Cluster[]


🏷️ count​

Retrieves the number of clusters in the collection.

Type​

number


🏷️ firstItem​

Retrieves the first cluster in the collection.

Type​

Cluster | undefined


🏷️ lastItem​

Retrieves the last cluster in the collection.

Type​

Cluster | undefined

▶️ Methods​


🔧 each​

Iterates through all clusters in the collection.

Signature​

each(fn: (cluster: Cluster) => boolean | void): boolean

Parameters​

NameTypeOptionalDescription
fn(cluster: Cluster) => boolean | voidNoFunction that is called for each cluster in the collection. If you want to stop the iteration, you can return true from this function to do so.

Return value​

Returns true if the iteration was stopped (break).


🔧 reverseEach​

Iterates through all clusters in the collection in reverse direction (starting with the last cluster).

Signature​

reverseEach(fn: (cluster: Cluster) => boolean | void): boolean

Parameters​

NameTypeOptionalDescription
fn(cluster: Cluster) => boolean | voidNoFunction that is called for each cluster in the collection. If you want to stop the iteration, you can return true from this function to do so.

Return value​

Returns true if the iteration was stopped (break).


🔧 sort​

Sorts the clusters using the supplied compare function.

Signature​

sort(fn: (a: Cluster, b: Cluster) => number): boolean

Parameters​

NameTypeOptionalDescription
fn(a: Cluster, b: Cluster) => booleanNoSpecifies the compare function. The compare function should return a number according to the following rules:
- a is less than b return -1;
- a is greater than b return 1;
- a is equal to b return 0.

Return value​

Returns true if the sort invoked a cluster position change.