【发布时间】:2017-11-02 02:05:27
【问题描述】:
我正在 keystone.js 应用程序模型中尝试从选择选项中选择与用户在另一个选择选项中选择的内容相关的内容.. 所以他会从第一个中选择,第二个选择选项应该只有与第一个选择的选项相关的数据.. 我希望有一个人可以帮助我 非常感谢
【问题讨论】:
标签: node.js keystonejs
我正在 keystone.js 应用程序模型中尝试从选择选项中选择与用户在另一个选择选项中选择的内容相关的内容.. 所以他会从第一个中选择,第二个选择选项应该只有与第一个选择的选项相关的数据.. 我希望有一个人可以帮助我 非常感谢
【问题讨论】:
标签: node.js keystonejs
你应该使用dependsOn选项。
例子..
type: { type: Types.Select, options: ['TypeOne','TypeTwo','TypeThree TypeFour' ], initial: true },
something: { type: Types.Text, dependsOn: { type: 'TypeThree' }, initial: true },
关系示例 - 您可以按照逻辑显示某些字段仅在依赖条件匹配时才会显示。
Adjustment.add({
type: { type: Types.Select, options: ['Booking','Shipment','Warehouse','Inventory' ], initial: true },
sku: { type: Types.Text, initial: true },
quantity: { type: Types.Number, initial: true, width: 'short' },
keyID: { type: Types.Relationship, ref: 'Order', dependsOn: { type: 'Booking' }, initial: true },
bookingID: { type: Types.Relationship, ref: 'Booking', dependsOn: { type: 'Booking' }, initial: true },
warehouse: { type: Types.Relationship, ref: 'Warehouse', dependsOn: { type: 'Warehouse' }, initial: true },
shipmentID: { type: Types.Text, dependsOn: { type: 'Shipment' }, initial: true },
});
【讨论】: