GS인증 AUIGrid v3.0.16

계층 구조에서 트리 아이콘을 데이터에 맞게 동적으로 변경할 수 있습니다.

예를 들면 트리 구조의 depth 에 따라 아이콘 설정, 책임자의 이름에 맞게 아이콘 설정 등 데이터를 보고 동적으로 변경 가능합니다.

treeIconFunction 을 정의 한 후 조건식에 따라 원하는 아이콘의 소스를 반환하면 됩니다.

해당 예제는 Lawrence 라는 책임자의 아이콘을 따로 하고, 태스크(task)의 depth 에 따라 아이콘을 설정한 모습입니다.

// 트리 아이콘을 바꿀 수 있는 트리 아이콘 펑션입니다.
treeIconFunction: function (rowIndex, isBranch, isOpen, depth, item) {
	let imgSrc = null;
	if (item.charge === "Lawrence") {
		imgSrc = "./assets/man4.png";
	} else {
		switch (depth) {
			case 1:
				imgSrc = "./assets/man1.png";
				break;
			case 2:
				imgSrc = "./assets/man2.png";
				break;
			case 3:
				imgSrc = "./assets/man3.png";
				break;
			default:
				imgSrc = "./assets/man4.png";
		}
	}
	return imgSrc;
}