是否有任何方法可以使用displayProperty显示模式的多个值



模式的displayProperty字段只接受单个属性名称,但我希望能够在芯片中显示多个值。

不直接,不。displayProperty只能指向一个属性。但是,您可以创建一个新属性,将API响应中的字段值连接在一起,并将其用作displayProperty。例如:

let LocationSchema = coda.makeObjectSchema({
properties: {
city: { type: coda.ValueType.String },
state: { type: coda.ValueType.String },
// Add an additional property to use as the display value.
display: { type: coda.ValueType.String },
// ...
},
displayProperty: "display",
// ...
});
pack.addFormula({
// ...
resultType: coda.ValueType.Object,
schema: LocationSchema,
execute: async function([], context) {
let location = await fetchLocationFromAPI(context);
return {
city: location.city,
state: location.state,
// Populate the display value using data from the API.
display: location.city + ", " + location.state,
},
},
});

更多信息可在文档中获得:https://coda.io/packs/build/latest/guides/advanced/schemas/显示值

最新更新