我如何访问 Kendo 中的树视图数据以便 Angular 递归地遍历树

发布于 2025-01-10 05:59:31 字数 1170 浏览 1 评论 0原文

我想知道是否有人知道如何访问 Kendo Angular TreeView 数据? 我像这样设置我的树视图组件,并允许用户通过拖放进行更改,这会触发添加后等事件。问题是该事件将具有拖动项目的新位置,但它没有太多信息新位置是什么,如果项目像项目 0_1_2 一样被拖出,并且 0_1_3 中有一个项目现在应该移动到 0_1_2。所以我正在寻找的是一种访问根节点的 dway,然后递归地向下遍历并使用新索引更新我的数据对象。

这就是我设置树视图组件的方式

<kendo-treeview
            [nodes]="data"
            textField="text"
            kendoTreeViewHierarchyBinding
            childrenField="items"
            [filterable]="true"
            kendoTreeViewExpandable
            [expandedKeys]="expandedKeys"
            [expandBy]="'text'"
            [kendoTreeViewCheckable]="checkableSettings"
            (checkedChange)="handleChecking($event)"
            [(checkedKeys)]="checkedKeys"
            checkBy="guid"
            kendoTreeViewDragAndDrop
            kendoTreeViewDragAndDropEditing
             (nodeDragStart)="log('nodeDragStart', $event)"
            (nodeDrag)="log('nodeDrag', $event)"
            (nodeDrop)="handleDrop($event)"
            (addItem)="log('addItem', $event)"
            (removeItem)="log('removeItem', $event)"
            (nodeDragEnd)="log('nodeDragEnd', $event)"
        >
        </kendo-treeview>

I am wondering if anyone knows how to access the Kendo Angular TreeView Data ?
I set up my treeview component like this and allow the user to make changes via drag and drop which fires off events like after add etc. The problem is that the event will have the new position of the dragged item but it doesnt have much info on what the new position is, if the item was drag out off like item was 0_1_2 and there was an item in 0_1_3 which should now move to 0_1_2. So what i am looking for is a dway to access the root node and then walk it down recursively and update my data object with new indexes.

This is how i setup my treeview component

<kendo-treeview
            [nodes]="data"
            textField="text"
            kendoTreeViewHierarchyBinding
            childrenField="items"
            [filterable]="true"
            kendoTreeViewExpandable
            [expandedKeys]="expandedKeys"
            [expandBy]="'text'"
            [kendoTreeViewCheckable]="checkableSettings"
            (checkedChange)="handleChecking($event)"
            [(checkedKeys)]="checkedKeys"
            checkBy="guid"
            kendoTreeViewDragAndDrop
            kendoTreeViewDragAndDropEditing
             (nodeDragStart)="log('nodeDragStart', $event)"
            (nodeDrag)="log('nodeDrag', $event)"
            (nodeDrop)="handleDrop($event)"
            (addItem)="log('addItem', $event)"
            (removeItem)="log('removeItem', $event)"
            (nodeDragEnd)="log('nodeDragEnd', $event)"
        >
        </kendo-treeview>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文