Skip to main content

find()

finds the item that corresponds to the specified parameters

find(rule: IFilterMode | DataCallback<T>): T;

Parameters:

rule: object | function - the search criteria

Returns:

The first object of the item that matches the specified criteria.

Example

//searching for a shape by the attribute key
const shape = diagram.data.find({by:"text",match:"Manager"});

//searching for a shape by the function
const shape = diagram.data.find(function(shape){
if(shape.text==="Manager"||shape.text==="Marketer"){return true}
});

Related sample: Diagram. Data. Finding necessary shape

The rule parameter:

  • if set as an IFilterMode object, the parameter contains the following attributes:
    • by - (string,function) the search criterion (either the key of the item attribute or a search function)
    • match - (string) the value of the item attribute
  • if set as DataCallback(item: T, index?: number, array?: T[]), the search will be applied by the rule specified in the function.

Finding the necessary item