0

I am using lightning-datatable to display a set of data. Now there are two fields that are formula fields. I am able to get the values of those fields from backend but not able to display them on Front end.

JS:

const columns = [
{
    label: 'Rig Name',
    fieldName: 'rigName',
    type: 'text',
    initialWidth: 130,
    typeAttributes: { label: { fieldName: 'rigName' } },
    sortable: true
},
{
    label: 'Last RV Date',
    fieldName: 'lastRVDate',
    initialWidth: 100,
    type: 'date-local',
    typeAttributes: {
        month: '2-digit',
        day: '2-digit'
    },
    sortable: true
},
{
    label: 'RV Scope',
    fieldName: 'scope',
    initialWidth: 100,
    type: 'text',
    typeAttributes: { label: { fieldName: 'scope' } },
    sortable: true
},
{
    label: ' RV No.',
    fieldName: 'name',
    initialWidth: 100,
    type: 'url',
    typeAttributes: { label: { fieldName: 'name' } },
    sortable: true
},
{
    label: 'Next RV Due Date (Min)',
    fieldName: 'minRVDate',
    type: 'text',
    initialWidth: 200,
    sortable: true
},
{
    label: 'Next RV Due Date (Max)',
    fieldName: 'maxRVDate',
    type: 'text',
    initialWidth: 200,
    sortable: true
}

];

HTML

   <div>
    <lightning-datatable
        key-field="id"
        columns={columns}
        data={activitiesList}
        hide-checkbox-column>
    </lightning-datatable>

Output:

enter image description here

5
  • Can you show us the Controller/Helper that populate activitiesList? What type the two formula fields (Date, String?) And does that type match the format you defined in "columns"? {label: 'Next RV Due Date (Min)', fieldName: 'fooDate', type: 'date'}, Commented Feb 8, 2021 at 16:53
  • Sure, Formula Fields are of Date type. I am fetching the result in a single query. Commented Feb 8, 2021 at 19:47
  • 1
    And what is the definition of your field in the 'columns'? It should look something like this: {label: 'Next RV Due Date (Min)', fieldName: 'fooDate', type: 'date'} Commented Feb 8, 2021 at 19:52
  • Yeah I tried wit date but its giving error as <lightning-formatted-date-time> The value attribute accepts either a Date object, a timestamp, or a valid ISO8601 formatted string with timezone offset. but we are getting the object value "Invalid Date" instead. Commented Feb 8, 2021 at 21:05
  • Adding the Date type worked. Commented Feb 9, 2021 at 0:01

0

You must log in to answer this question.

Browse other questions tagged .