2

There is an Aura lightning:listView, but presently not a LWC lightning-list-view. For most Aura components there is an LWC equivalent. That allows the composting composing of LWCs inside other LWCs which is a great way to leverage what has already been built rather than having to start from scratch.

Why no LWC in this case?

5

While looks there is no component which is very similar to aura version there is api thats of BETA quality.

There is a lightning/uiListApi module to get List views data and metadata in LWC. Note that as of today it is under BETA.

There is also a sample code in the trailhead recipe repo

import { LightningElement, wire } from 'lwc';
import { getListUi } from 'lightning/uiListApi';

import CONTACT_OBJECT from '@salesforce/schema/Contact';
import NAME_FIELD from '@salesforce/schema/Contact.Name';

export default class WireListView extends LightningElement {
 @wire(getListUi, {
    objectApiName: CONTACT_OBJECT,
    listViewApiName: 'All_Recipes_Contacts',
    sortBy: NAME_FIELD,
    pageSize: 10
})
listView;

 get contacts() {
    return this.listView.data.records.records;
 }
}

You can combine this with the lightning-datatable to get one similar to the list view.

| improve this answer | |
  • 1
    Thanks Mohith. No word on a lightning-list-view? Any idea why not? – Keith C Apr 1 at 16:13
  • 1
    @keith No word on it but I will let you know once I hear something on it. – Mohith Shrivastava Apr 2 at 3:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.