pm-controls
Version:
ProModel Controls
52 lines (44 loc) • 1.51 kB
text/typescript
import { Component,
Input,
OnInit,
Output,
EventEmitter,
ViewContainerRef,
ViewChild,
TemplateRef,
SimpleChanges } from '@angular/core';
export class TreeItemComponent {
ItemsSource: Array<any>;
ItemTemplate: TemplateRef<any>;
SelectedItems: Array<any> = [];
SelectedItem: any;
DisplayMemberPath: any; // should be property name or function.
ChildPath: any; // should be property name or function.
SelectionMode: string = "SelectionMode.Single";
SelectedItemsChange: EventEmitter<any> = new EventEmitter<any>();
SelectedItemChange: EventEmitter<any> = new EventEmitter<any>();
OnClick(item: any) {
item._isExpanded = !item._isExpanded;
//this.IsExpanded = !this.IsExpanded;
}
HasChildren(item) : boolean {
if (!item)
return false;
if (!this.ChildPath)
return false;
var items = <Array<any>> item[this.ChildPath];
return items && items.length > 0;
}
GetChildren(item) : Array<any> {
if (!item)
return;
if (!this.ChildPath)
return;
return item[this.ChildPath];
}
}