본문으로 건너뛰기

find()

설명

지정된 매개변수에 해당하는 항목을 찾습니다

사용법

find(rule: object): object;

// 또는

find(rule: function): object;

매개변수

  • rule - (필수) 지정할 수 있는 검색 기준:
    • 다음 매개변수를 포함하는 객체로 지정:
      • by: string | function - 검색 기준(항목 속성의 키 또는 검색 함수)
      • match: string - 항목 속성의 값
    • 함수로 지정: DataCallback(item: T, index?: number, array?: T[])

반환값

이 메서드는 지정된 기준과 일치하는 항목의 첫 번째 객체를 반환합니다

예제

const diagram = new dhx.Diagram("diagram_container", {
type: "default"
});
diagram.data.parse(data);

//속성 키로 shape 검색
const shape = diagram.data.find({ by: "text", match: "Manager" });

//함수에 지정된 규칙으로 shape 검색
const shape = diagram.data.find((shape) => {
if(shape.text==="Manager"||shape.text==="Marketer"){return true}
});

관련 문서: 필요한 항목 찾기

관련 샘플: Diagram. Data. 필요한 Shape 찾기