The <apex:enhancedList>
component allows you to embed a standard Salesforce list view directly into a Visualforce page. It provides a convenient way to display records in a tabular format, just like in the native Salesforce UI.
Why Use <apex:enhancedList>
?
- Displays record lists based on existing list views.
- Offers a familiar Salesforce look and feel.
- Supports sorting, filtering, inline editing, and pagination.
Basic Syntax
xmlCopyEdit<apex:enhancedList type="Account" height="300" rowsPerPage="10"/>
Key Attributes
Attribute | Description |
---|---|
type | The object whose records you want to display (e.g., Account , Contact ) |
height | The height of the list in pixels |
rowsPerPage | Number of rows to display per page |
listId | (Optional) The ID of a specific list view to use |
id | (Optional) Assign an ID to the component for styling or JS manipulation |
Example: Display a List of Opportunities
xmlCopyEdit<apex:page>
<apex:enhancedList type="Opportunity" height="400" rowsPerPage="20"/>
</apex:page>
This shows the default list view for Opportunities with 20 rows per page.
Use Cases
- Dashboards and Homepages: Quickly display important object lists.
- Custom Apps: Embed native list views inside custom UIs.
- Admin Pages: Provide easy record management for users.