Universal table is a component for Salesforce.com, which allows creating a multi-function table with many useful features easily.
UniversalTableCMP consists of four parts: a component itself (UniversalTableCMP.component), its controller (UniversalTableController.cls), class to store records (NewRow.cls) and test class (TestUniversalTable.cls). The component creates the most versatile table that can be edited. It can work with 50000 rows.
To get started, four things need to be sent into the component with help of attributes:
- 'ListSize' – list of possible numbers of rows displayed per page. The first element will be applied. This attribute is not required. If a user does not send it into the component, the standard list will be applied.
- 'WhereCondition' – additional conditions for queries that will be placed after WHERE.
- 'ObjectsName' – a name of the SObject from which information for the table will be extracted.
- 'AllFields' - a special query that retrieves all the fields from the FieldSet. For example: SObjectType.ExOb__c.FieldSets.TotalFS.getFields(), where ExOb__c – SObject’s name, and TotalFS – name of this SObject’s FieldSet. The request may be triggered by the method of the controller.
It should look like this:
It is all that is necessary for the proper operation of the component.
The completed table looks like this.
To move from page to page you should use image-links and links 'Next' and 'Previous'. If you are on the first or on the last page, then the appropriate link will be disable and you cannot press it.
On the right the current page number is displayed.
On the left user can set a number of rows displayed per one page. If you hover the cursor over the selectList, the information about displayed lines will pop up (the first and last row numbers, the total number of rows).
Next is the link 'optimum adjustment', pressing which you'll have a more accurate adjustment of each column width based on each record length.
If a user needs to sort the table by one of the columns, he should click on its title or arrow of this column. The arrow shows the order (ascending or descending) in which the table is sorted.
If you want to make a new record in the table, you need to press 'New'. This will open a popup of a standard page. After it closed your table will be reloaded automatically and a notification will appear. 'Edit' link works the same way.
If you want to delete a record from the table, press 'Del' link. After the operation, a notification will appear and your table will be reloaded automatically.
The component has a test coverage:
- UniversalTableControllerS – 100%.
- NewRow – 100%.