Skip to content

The way the tree control customizes the display content is too cumbersome #4256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task
zealpane opened this issue Jun 24, 2021 · 8 comments
Closed
1 task
Labels

Comments

@zealpane
Copy link

zealpane commented Jun 24, 2021

  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

一般原始数据都是比较纯粹的数据。想要自定义树控件内部的显示内容,必须要对treeData的每一项遍历加上要求的属性,太繁琐。
为什么不提供一个系统默认的插槽呢?对树内部的自定义渲染会简化好多

What does the proposed API look like?

无论是通过render()函数,还是通过插槽,体验都好

@github-actions github-actions bot changed the title 树控件自定义显示内容的方式太繁琐 The way the tree control customizes the display content is too cumbersome Jun 24, 2021
@zkwolf
Copy link
Member

zkwolf commented Jun 25, 2021

举个例子?自定义的展示内容的话title插槽应该就够了

@zealpane
Copy link
Author

zealpane commented Jun 25, 2021

举个例子?自定义的展示内容的话title插槽应该就够了

代码中使用treeData赋值

:tree-data="treeData"

比如接口返回数据只是有关业务的,其中有些项点击后在右侧布局没有直接内容,就想根据当前项的另一个属性进行判断,在树上用不同颜色标识或者当前项禁止点击。
想要实现这个需求,就不方便。
再有就是有些场景下,可能想在树的每一项后面跟着一些图标按钮操作,也不能直接实现。

image

BTW

  1. 现在树控件在第二次点击的时候是取消点击。但其实很多业务情况下,即使是第二次点击,目的也是选择当前项的,希望考虑一下
  2. 树很多时候都是异步加载赋值的,配置的默认展开所有节点在这种场景下不生效。有一种方式就是加上
v-if="treeNode.length"

是否可以把这种方案加到文档之中?

@zkwolf
Copy link
Member

zkwolf commented Jun 28, 2021

https://2x.antdv.com/components/tree-cn#components-tree-demo-context-menu 参考一下这个右键菜单的demo,title是全局的slot,每一项都会生效的

@zealpane
Copy link
Author

https://2x.antdv.com/components/tree-cn#components-tree-demo-context-menu 参考一下这个右键菜单的demo,title是全局的slot,每一项都会生效的

这个是2.x的,title在Tree props,应该是没问题的;
可是我们现在项目中用的是1.x的,而在1x中title是TreeNode props ,无法这样用?

在1.x中准备增加这一项吗?

@zkwolf
Copy link
Member

zkwolf commented Jun 29, 2021

需要的话我可以提个pr,这个还是比较经常用到的,所以我2.x给加上了

@zealpane
Copy link
Author

zealpane commented Jun 29, 2021

需要的话我可以提个pr,这个还是比较经常用到的,所以我2.x给加上了

嗯是的。如果没在计划内的话,我也可以提交pr。

还有请看一下这两个问题

  1. 现在树控件在第二次点击的时候是取消选中。但其实很多业务情况下,即使是第二次点击,目的也是选择当前项而非取消的,这个是否考虑处理
  2. 树很多时候都是异步加载赋值的,配置的默认展开所有节点在这种场景下不生效。有一种方式就是加上
    v-if="treeNode.length"
    是否可以把这种方案加到文档之中?

@Hccake
Copy link

Hccake commented Aug 18, 2021

需要的话我可以提个pr,这个还是比较经常用到的,所以我2.x给加上了

TreeSelect 的 title 也不支持全局定义 slot,而且如果数据中有 title 属性,scopedSlots 也会失效。
现在每次都要前端处理下服务端的返回数据,大佬可以优化下吗。

参看 issues 连接: #2826

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants