-
Notifications
You must be signed in to change notification settings - Fork 1
WorkListViewComponent JavaScript
Ethan Dunzer edited this page Aug 29, 2024
·
1 revision
The WorkListViewComponent is a Lightning Web Component (LWC) designed to display a list of work records assigned to the current user. The component leverages an Apex controller to fetch data and includes pagination controls to handle large datasets. The component ensures that users can navigate through work records efficiently, with an emphasis on user experience and responsiveness.
-
@track workRecords
: Holds the list of work records retrieved from the server. -
@track columns
: Defines the columns to be displayed in the datatable. -
@track page
: Keeps track of the current page number for pagination. -
@track pageSize
: Specifies the number of records to display per page. -
@track totalRecords
: Stores the total number of records returned by the server. -
@track totalPage
: Calculates the total number of pages based on totalRecords and pageSize. - wiredIdeasResult: Stores the result of the getWorkRecords Apex method for use in refreshApex.
-
@wire(MessageContext)
: Provides access to the Lightning message service for inter-component communication.
-
wiredWorkRecords(result)
: Handles the result from the getWorkRecords Apex method, processing the data and setting up pagination. -
updateTotalPages()
: Calculates the total number of pages based on the total records and page size. -
isPreviousDisabled()
: Returns true if the user is on the first page, disabling the "Previous" button. -
isNextDisabled()
: Returns true if the user is on the last page, disabling the "Next" button. -
handlePrevious()
: Navigates to the previous page and refreshes the data accordingly. -
handleNext()
: Navigates to the next page and refreshes the data accordingly. -
handleRowSelection(event)
: Handles row selection in the datatable, sending a message through the Lightning message service.
The pagination controls allow users to navigate through pages of work records. The page property is incremented or decremented when users click the "Next" or "Previous" buttons. The component automatically resets to the first page when a new work record is selected, ensuring that users don't miss any data when switching between records.