I want to grab list views in Aura by sobjectType and list view name. I already made a component that does a request, but fail to expose the data to Aura. Attribute change handler never fires and upon button click return default value.
Consumer code:
<aura:attribute name="listView" type="Object" access="private" default="{}"/>
<aura:attribute name="selectedView" type="Object" access="private"/>
<lightning:button label="what" onclick="{!c.what}"/>
<c:wireListView
listViewApiName="{!v.selectedView.NamespacePrefix+'__'+v.selectedView.DeveloperName}"
objectApiName="{!v.selectedObject}"
listView="{!v.listView}"/>
wireListView markup:
<template>
<lightning-card title="WireListView" icon-name="custom:custom67">
<template if:true={listView.data}>
<div class="slds-m-around_medium">
<template for:each={contacts} for:item="contact">
<p key={contact.fields.Id.value}>
{contact.fields.Name.value}
</p>
</template>
</div>
</template>
view name {listViewApiName}
sobject name {objectApiName}
</lightning-card>
</template>
(Note that markup will be gone in future, I need a modular, headless component)
wireListView code:
import { LightningElement, wire, track, api } from 'lwc';
import { getListUi } from 'lightning/uiListApi';
export default class WireListView extends LightningElement {
@api objectApiName;
@api listViewApiName;
@api listView;
@wire(getListUi, {
objectApiName: '$objectApiName',
listViewApiName: '$listViewApiName'
})
listView
get contacts() {
return this.listView.data.records.records;
}
}