amis icon indicating copy to clipboard operation
amis copied to clipboard

Select怎样动态绑定,获取source返回的列

Open mingpeng2005 opened this issue 7 years ago • 7 comments

如题

mingpeng2005 avatar Aug 27 '19 02:08 mingpeng2005

你意思是数据适配?

RickCole21 avatar Aug 27 '19 02:08 RickCole21

如下,返回了一个list,我指定了下拉选项的列; 列表显示正确了,但是选择一行以后,无法把name带到主页面,是不是还缺什么设置。 { name: "order-type", label:"订单类型", type: "select",
source:"http://localhost:8770/resource-dispatcher/orderType/findAll", valueField: "id", labelField: "name",
autoFill:{"order-type": "${name}"}, clearable: true, searchable: true, required: true }

mingpeng2005 avatar Aug 27 '19 06:08 mingpeng2005

你把 autoFill 删了吧,本来选中后就会把 value 设置给 order-type 然后,这个 autoFill 又设置了一次,而且设置的 name 导致选择关联不上了。 想要获取 name,倒是可以把 autoFill 里面的第一个 key 换个其他表单项的名字。比如 {type: "hidden", name: "order-name"}

2betop avatar Aug 27 '19 06:08 2betop

就是因为value选不上我才用autofill的,去掉后,选择选项后一直是“请选择”

mingpeng2005 avatar Aug 27 '19 07:08 mingpeng2005

那应该是 labelField 和 valueField 有问题,不要修改这个,把接口改成以下这种格式试试?

{
 status: 0,
msg: '',
  data: {
   options: [
    {label: xxx, value: xxxx}
  ]
  }
}

或者用接口适配器,适配成这种格式。

2betop avatar Aug 27 '19 07:08 2betop

试过了,好像不行,目前是不是没有更好的办法了,我看text里面也有这个问题

mingpeng2005 avatar Aug 28 '19 02:08 mingpeng2005

试下最新版是否还有问题

RickCole21 avatar Aug 05 '20 12:08 RickCole21