javascript 有没有办法使用displayProperty显示一个模式的多个值

cvxl0en2  于 2023-02-15  发布在  Java
关注(0)|答案(1)|浏览(110)

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

hpcdzsge

hpcdzsge1#

不能直接指向。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/#display-value

相关问题