Angular Primeng v11.x如何在树成分中实现TreesElect功能

发布于 2025-01-22 19:53:20 字数 506 浏览 3 评论 0原文

我正在使用Primeng V11.X,并且正在使用P-Tree显示带有复选框的层次结构视图。但是我想在p-Treeselect中的下拉列表中显示此内容。不幸的是,目前我无法升级Primeng。有办法实现这一目标吗?由于P-Tree的高度过高,因此想移动下拉选项。

当前代码:

<p-tree
    #tree
    [value]="nodes"
    selectionMode="checkbox"
    [propagateSelectionUp]="true"
    [propagateSelectionDown]="true"
    (onNodeUnselect)="onNodeUnselect()"
    (onNodeSelect)="onNodeSelect()"
    disabled="disabled || readonly"
></p-tree>

谢谢

I am using primeng v11.x and i am using p-tree to display hierarchy view with checkbox. but i want to display this inside a dropdown as in p-treeselect. unfortunately i can't upgrade primeng at the moment. is there a way to achieve this? because the p-tree is taking too much height, wanted to move to dropdown option.

Current code:

<p-tree
    #tree
    [value]="nodes"
    selectionMode="checkbox"
    [propagateSelectionUp]="true"
    [propagateSelectionDown]="true"
    (onNodeUnselect)="onNodeUnselect()"
    (onNodeSelect)="onNodeSelect()"
    disabled="disabled || readonly"
></p-tree>

expected functionality as in https://www.primefaces.org/primeng/treeselect

Thanks

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷︶言冷语的世界 2025-01-29 19:53:21

您可以放置​​ p-tree 组件a p-overlaypanel 组件。

<p-overlayPanel #op [showCloseIcon]="true" [style]="{ width: '450px' }">
  <ng-template pTemplate>
    <p-tree
      [value]="files"
      selectionMode="checkbox"
      (onNodeSelect)="nodeSelect($event)"
      (onNodeUnselect)="nodeUnselect($event)"
      [(selection)]="selectedFiles"
    ></p-tree>
  </ng-template>
</p-overlayPanel>

我创建了一个demo

You can place the p-tree component inside a p-overlayPanel component.

<p-overlayPanel #op [showCloseIcon]="true" [style]="{ width: '450px' }">
  <ng-template pTemplate>
    <p-tree
      [value]="files"
      selectionMode="checkbox"
      (onNodeSelect)="nodeSelect($event)"
      (onNodeUnselect)="nodeUnselect($event)"
      [(selection)]="selectedFiles"
    ></p-tree>
  </ng-template>
</p-overlayPanel>

I created a demo here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文