您在此处:
非营利组织礼品条目网格中的自定义 Lightning Web 组件
了解自定义 Lightning Web 组件如何将数据从礼品条目网格移出和移入礼品条目网格。
| 所需版本 |
|---|
| 适用于:Lightning Experience |
适用于:带 Education Cloud 的 Enterprise、Performance、Unlimited 和 Developer Edition 适用于:带 Nonprofit Cloud 的 Enterprise、Unlimited 和 Developer Edition |
- 从礼品条目网格发送到组件的属性
礼品条目网格通过单元格组件的 params 属性和模态的 rowData 属性,将行数据传输到自定义 Lightning Web 组件。 - 将数据发送回礼品输入网格
列模式和单元格编辑组件使用不同的机制将数据返回到礼品条目网格。 - 返回数据的注意事项
在将数据返回礼品条目网格时,请考虑选项列表和查找字段的这些规则。
从礼品条目网格发送到组件的属性
礼品条目网格通过单元格组件的 params 属性和模态的 rowData 属性,将行数据传输到自定义 Lightning Web 组件。
| 所需版本 |
|---|
| 适用于:Lightning Experience |
适用于:带 Education Cloud 的 Enterprise、Performance、Unlimited 和 Developer Edition 适用于:带 Nonprofit Cloud 的 Enterprise、Unlimited 和 Developer Edition |
| 属性 | 备注 |
|---|---|
| params |
|
| rowData |
|
将数据发送回礼品输入网格
列模式和单元格编辑组件使用不同的机制将数据返回到礼品条目网格。
| 所需版本 |
|---|
| 适用于:Lightning Experience |
适用于:带 Education Cloud 的 Enterprise、Performance、Unlimited 和 Developer Edition 适用于:带 Nonprofit Cloud 的 Enterprise、Unlimited 和 Developer Edition |
列模式
列模态呈现在包装 Lightning Web 组件中,该组件包括模态标题(如模板中定义)以及继续和取消按钮。
继续按钮是用户单击以关闭自定义模式的内容。它将调用这些必需的公开函数:
| 函数 | 描述 |
|---|---|
@api validate() |
返回具有两个属性的对象:
|
@api getComponentValues() |
返回要应用到行的 key:value 属性集:
|
单元格编辑组件
要从单元格编辑组件将数据返回到礼品条目网格:
- 构建对象作为消息,以返回到礼品条目网格。
- 将事件发布到
lightning__giftEntryGridComponentAction消息渠道。
消息正文的内容很严格。按照此示例的结构:
// Build the "message" object to send back to
// Gift Entry Grid following the documented contract
const message = {
// Required properties (do not change the values below)
action: "ColumnEdit",
componentName: this.tagName,
colId: this._params?.colDef?.colId,
// 'details' is an optional property:
// - include if there is data to write to the row
// in Gift Entry
details: {
// rowId and rowIndex must be included in details
rowId: this.params?.data?.id, // Required
rowIndex: this.params?.data?.rowIndex, // Required
// All GiftEntry fields to write to rowData
// and as object in a key:value collection.
// To clear the value of a field on the GiftEntry rowData
// object, return null instead of undefined
giftEntryFields : { key: value, ... },
// rowProperties is optional, but if passed can be
// referenced by other custom components. Data in this
// object are not persisted to the GiftEntry record.
rowProperties: { key : value, ... },
// Special Use: If your custom column component is
// forcing a matched gift transaction, use these
// properties to send the matching transaction ID
// and NAME back to grid for proper handling:
matchingGiftTransactionId: {giftTransactionId},
matchingGiftTransactionName: {giftTransactionName}
}
}
返回数据的注意事项
在将数据返回礼品条目网格时,请考虑选项列表和查找字段的这些规则。
| 所需版本 |
|---|
| 适用于:Lightning Experience |
适用于:带 Education Cloud 的 Enterprise、Performance、Unlimited 和 Developer Edition 适用于:带 Nonprofit Cloud 的 Enterprise、Unlimited 和 Developer Edition |
选项列表字段注意事项:
- 如果选项列表字段作为简单字符串返回,则该值应代表标签和 API 名称不同时选项列表 API 名称。
- 选项列表字段也可以以
{ value: xx, displayValue: zz }形式返回为对象。以下示例:{ giftType: { value: “Organizational”, displayValue: “Organizativo/Doméstico” } }
查找字段注意事项:
- 不是礼品条目网格中的列的查找字段只能在响应对象中作为 ID 字符串返回。例如,
{MyLookupFieldId__c: ‘xxx00000000’} - 作为礼品条目网格中的字段列的查找字段,例如市场活动和推广源代码,应该从对象表单中的自定义 Lightning Web 组件返回,以确保它们在网格中正确呈现。以下是示例:
Campaign: { Id: {campaignId}, Name: {campaignName} }

