您位於此處:
非營利組織的禮物項目網格中的自訂 Lightning Web 元件
瞭解自訂 Lightning Web 元件如何將資料從「禮物項目網格」移動到「禮物項目網格」中。
| 所需版本 |
|---|
| 提供版本:Lightning Experience |
提供版本:具備 Education Cloud 的 Enterprise、Performance、Unlimited 及 Developer Edition 提供版本:具備 Nonprofit Cloud 的 Enterprise、Unlimited 及 Developer Edition |
- 從禮物項目網格傳送至元件的內容
「禮物項目網格」會透過儲存格元件的 params 內容,以及 modals 的 rowData 內容,將資料列資料傳送至自訂 Lightning Web 元件。 - 將資料傳送回禮物項目網格
資料欄強制回應和儲存格編輯元件使用不同的機制將資料傳回至「禮物項目網格」。 - 傳回資料的考量事項
將資料傳回「禮物項目網格」時,請針對選項清單與對應欄位考量下列規則。
從禮物項目網格傳送至元件的內容
「禮物項目網格」會透過儲存格元件的 params 內容,以及 modals 的 rowData 內容,將資料列資料傳送至自訂 Lightning Web 元件。
| 所需版本 |
|---|
| 提供版本:Lightning Experience |
提供版本:具備 Education Cloud 的 Enterprise、Performance、Unlimited 及 Developer Edition 提供版本:具備 Nonprofit Cloud 的 Enterprise、Unlimited 及 Developer Edition |
| 內容 | 描述 |
|---|---|
| 參數 |
|
| 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” } }
對應欄位考量事項:
- 非「禮物項目網格」中資料欄的對應欄位只能在回應物件中作為識別碼字串傳回。例如,
{MyLookupFieldId__c: ‘xxx00000000’} - 「禮物項目網格」中欄位欄位的對應欄位 (例如行銷活動和拓展來源程式碼) 應從物件表單中的自訂 Lightning Web 元件傳回,以確保其在網格中正確呈現。範例如下:
Campaign: { Id: {campaignId}, Name: {campaignName} }

