Skip to content
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

Tree 中TreeNode从treeData取值,没办法配置相应的key及title对应的取值字段 #24282

Closed
1 task
davycun opened this issue May 19, 2020 · 36 comments
Closed
1 task
Assignees
Labels
❓FAQ issues would be discussed a lot Inactive

Comments

@davycun
Copy link

davycun commented May 19, 2020

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

What problem does this feature solve?

解决了从服务端加载的数据中,可以不需要特别增加字段key和title才能适配TreeNode。否则只能自己构造Tree,但是自己构造提示API已经过时,建议使用treeData

What does the proposed API look like?

<Tree treeDataField={title:'name',key:'code'} />

@zombieJ

This comment has been minimized.

@waylon-edmodo
Copy link

不太明白,为什么级联组件愿意提供这个支持,树选择器就不能提供。

@waylon-edmodo
Copy link

#24986

@burylife
Copy link

支持自定义这种还是非常有必要的,我们目前用的是ztree,id,name这种,想迁移到这个上面来,发现自己再重新包裹,加上树节点万级别,有些层级还很深,重新渲染成title这种使用起来,等于又重新渲染树了

@zhans1099
Copy link

为啥Cascader就有而TreeSelect就没 而且也不是说无法添加

@lyyzhh
Copy link

lyyzhh commented Jun 22, 2020

强烈建议增加fieldNames

@662
Copy link

662 commented Jun 28, 2020

数据建议自行处理。

@zombieJ 你是认真的吗

@afc163 afc163 added the ❓FAQ issues would be discussed a lot label Jun 28, 2020
@msotnikov
Copy link

msotnikov commented Aug 17, 2020

Can you extend simpleDataMode? This prop already takes every row and also can get a title and/or label fields.

@lwpersonal
Copy link

所以是还没解决吗?关键是自己构建 treeNode 还报错。

@iceycc
Copy link

iceycc commented Sep 23, 2020

为啥不支持下呢

@yoyo837
Copy link
Contributor

yoyo837 commented Sep 23, 2020

伪代码:

treeData= {
   title: <Component /> 
}

不行么?

@zhengAnBin
Copy link

强烈建议加,要不然也得告诉我们是什么原因导致加不了!

@p-efimenko
Copy link

Vue version of Ant has this feature

https://www.antdv.com/components/tree/#components-tree-demo-replacefields

@wellenzhong
Copy link

手动添加了,唉

  const convertData = (data: Array<any>) => {
    data.forEach((item) => {
      item.title = item.name;
      item.key = item.id;
      if (item.children) {
        convertData(item.children);
      }
    });
  };

@jinhongjie007
Copy link

jinhongjie007 commented Dec 26, 2020

这个真的需要支持一下 因为好多都是id name这样的,如果支持的话就很棒了

@xuek9900
Copy link

头疼

@afc163
Copy link
Member

afc163 commented Jan 6, 2021

Tree/TreeSelect 可以统一支持一下,类似 Cacasder 的 fieldNames。

@bj-white
Copy link

bj-white commented Jan 7, 2021

@zombieJ 能支持一下吗 如果自己处理数据的话 还要用递归 递归效率慢 加个映射很实用呀

@jinhongjie007
Copy link

呼声如此之高的一个需求 不知道现在是什么进展?

@chengzequn
Copy link

这个需求现在支持了吗?为啥看到提这个问题的issues都被关闭了,这个需求真的很需要!很多情况下获取到的数据的字段名并不是title,value,这个需求在哪个版本能支持一下?

@yoyo837
Copy link
Contributor

yoyo837 commented Jan 15, 2021

同一个问题,留一个issus就好了。就是当前这个。

@LiuYnag
Copy link

LiuYnag commented Jan 21, 2021

Tree、TreeSelect、Select、级联选择器我感觉都需要这个功能的

@cbojaca
Copy link

cbojaca commented Mar 11, 2021

Hi to all (Great components BTW), is there any workaround that we can use in the meantime?.. I'm facing the same issue , I'll need to show a different field instead of the title.

thanks in advanced

@FlyingRadish
Copy link

Any progress? I'm facing the same issue too

@github-actions github-actions bot removed the Inactive label May 4, 2021
@kkkisme
Copy link
Contributor

kkkisme commented May 25, 2021

same issue here

@lovewinders
Copy link

I also encountered this problem

@jianghai
Copy link

+1

@joker77877
Copy link

我也遇到相同问题,可以解决一下么,都过了一年多了

@ghtao666
Copy link

+1

1 similar comment
@409380713
Copy link

+1

@web-linda
Copy link

感觉这个功能还是很有必要的

@gezhicui
Copy link

这个api还没出来吗??

@web-linda
Copy link

这个api还没出来吗??

no

@afc163
Copy link
Member

afc163 commented Oct 12, 2021

See #31395

@afc163 afc163 closed this as completed Oct 12, 2021
@Jarryxin
Copy link

See #31395

您好, FieldNames 属性支持修改 key为其他标志,但是 interface DataNode 对 key 是必须的,所以设置 fieldNames = { key: 'id' },仍需要向数据增加 key 属性,请问有办法解决吗

@HJM515
Copy link

HJM515 commented Apr 12, 2023

See #31395

您好, FieldNames 属性支持修改 key为其他标志,但是 interface DataNode 对 key 是必须的,所以设置 fieldNames = { key: 'id' },仍需要向数据增加 key 属性,请问有办法解决吗

参考示例可解决:https://codesandbox.io/s/objective-roentgen-hkiq98?file=/src/App.tsx:43-56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓FAQ issues would be discussed a lot Inactive
Projects
None yet
Development

No branches or pull requests