You can change the value of any argument to the getListUi
api and it will automatically call the wire method again.
To elaborate on this, as mentioned in the documentation: here
The getListUi
can take any of the following parameters:
- objectApiName
- listViewApiName
- sortBy
- pageSize
- pageToken
Now if you change the value of any 1 variable that is assigned to these parameters the getListUi
will automatically be triggered to fetch the new results.
Considering the usecase mentioned in the question, it seems that the objectApiName, listViewApiName will be constant. Hence as a workaround, you can try changing the value of variables holding the pageSize or sortBy to retrigger the fetch of records.
Note: This is useful when we need to fetch different listviews of different objects and changing pageSize or sortBy will only serve as a workaround.
Sample code:
pageSize = 10;
selectedObject = 'Account';
selectedListView = 'All';
@wire(getListUi, {
objectApiName: '$selectedObject',
listViewApiName: '$selectedListView',
pageSize: '$pageSize',
pageToken: '$pageToken'
})
wiredlistView(result) {
if (result.data) {
// do somethings
} else if (result.error) {
// do something
}
}
handleButtonClick() {
this.pageSize = 11; //will call getListUi again
}