如何在Angular Kendo树视图中重新选择一个项目

时间:2018-06-25 20:26:28

标签: kendo-ui-angular2 kendo-treeview

使用Kendo UI selectedKeys属性,保留用户选择的treeview项目。我也有一个使用@ViewChild()定义的treeview元素。我的问题是如何以编程方式选择项目。

这是我的参考资料: https://www.telerik.com/kendo-angular-ui/components/treeview/selection/

这是我更新treeviewData数组的地方:

// BIND TO KENDO TREEVIEW
that.treeviewData = new Array();
that.treeviewData.push(tree);

this.selectedKeys显示:

 ["0_0_0_2_0"]

和我的treeview模板代码:

<kendo-treeview #treeview id='treeview'
	[nodes]="treeviewData"
	[textField]="['SiteName', 'LocationName', 'HostName', 'Url']"

	kendoTreeViewExpandable
	[(expandedKeys)]="expandedKeys"
	(expand)="treeExpand($event)"

	kendoTreeViewSelectable="{ mode: 'single' }"
	[selectBy]='SiteName || LocationName || HostName || Url'
				
	[(selectedKeys)]="selectedKeys"

	(selectionChange)="treeSelection($event)"

	kendoTreeViewHierarchyBinding
	childrenField="subs" > 
	
	<ng-template kendoTreeViewNodeTemplate let-dataItem>					
		<span style="padding-left: 5px;">
			{{dataItem.LocationName || dataItem.HostName ||  dataItem.SiteName )}}
		</span>
	</ng-template>
</kendo-treeview>

0 个答案:

没有答案