Grid - Custom Inline Component
Introduction
All GridMate components can be used as inline components just by configuration. However there is some situations where a custom component is required to address the business needs.
To address this type of use cases, you can implement your own Aura or LWC component. Both components should have recordId as an attribute.
Aura Implementation
Aura Component
Our use case is to display a relative date based on the close date like a timer. Let's go ahead and start our custom Aura component using Lightning Data Service and relativeDateTime lightning component.
<aura:component implements="force:hasRecordId" access="global">
<aura:attribute name="style" type="String" access="global" />
<aura:attribute name="recordData" type="Object" />
<aura:attribute name="recordError" type="String" />
<aura:attribute name="closeDate" type="Object" />
<aura:handler name="change" value="{!v.recordData}" action="{!c.handleRecordDateChange}" />
<force:recordData
aura:id="recordData"
recordId="{!v.recordId}"
fields="Name,CloseDate"
targetFields="{!v.recordData}"
targetError="{!v.recordError}"
/>
<aura:if isTrue="{! v.closeDate }">
<div class="slds-align_absolute-center">
Closing
<span style="{!v.style}">
<lightning:relativeDateTime value="{!v.closeDate}" />
</span>
</div>
</aura:if>
</aura:component>
Inline Component Configuration
Our Aura component is ready. Let's go ahead and configure it as an inline component as below. Note that we can have dynamic attributes to customize the behavior per grid if needed. In our example, we are passing the style of the timer.
[
{
"component": "c:CloseDateTimerComponent",
"attributes": {
"style": "font-size:large;color:blue"
}
}
]

LWC Implementation
LWC Component
LWC is also an option to implement an inline component. Below is the LWC version of the Close Date Timer component implemented above.
<template>
<template if:true={closeDate}>
<div class="slds-align_absolute-center">
Closing
<span style={timerStyle}>
<lightning-relative-date-time value={closeDate}>
</lightning-relative-date-time>
</span>
</div>
</template>
</template>
Inline Component Configuration
Let's go ahead and configure the inline component as below:
[
{
"component": "c:closeDateTimerLWC",
"attributes": {
"timerStyle": "font-size:large;color:blue"
}
}
]
And obviously we get the same result as a above.

Last updated
Was this helpful?