Code Snippet #4
For the sort dropdown
This code snippet uses the ClearCollect function to create a collection named locSortDropdown and populate it with a table of data.
   ClearCollect(
        locSortDropdown,
        Table(
            {
                DisplayColumn: "No sort", ColumnName: ""
            },
            {
                DisplayColumn: "State", ColumnName: "State"
            },
            {
                DisplayColumn: "Friend Name", ColumnName: "FriendName"
            },
            {
                DisplayColumn: "Last Updated", ColumnName: "LastUpdated"
            }
        )
    );
Explanation
- 
    ClearCollect Function: - ClearCollect(collectionName, items...): This function clears any existing data in the specified collection (collectionName) and then collects theitemsinto it. In your code,locSortDropdownis the name of the collection being created or updated.
- 
    Table Function: - Table(...)is used to create a table with the specified records. Each record is defined within curly braces{}.
- 
    Records in the Table: - The table created in your code consists of four records, each with two properties: DisplayColumnandColumnName.- { DisplayColumn: "No sort", ColumnName: "" }: The first record.- DisplayColumnis a label that might be displayed in the UI, and- ColumnNameis an empty string, indicating no sorting.
- { DisplayColumn: "State", ColumnName: "State" }: The second record. This indicates that items can be sorted by a column named “State”.
- { DisplayColumn: "Friend Name", ColumnName: "FriendName" }: The third record for sorting by a “FriendName” column.
- { DisplayColumn: "Last Updated", ColumnName: "LastUpdated" }: The fourth record for sorting by a “LastUpdated” column.
 
In summary, this code is creating a collection named locSortDropdown which is intended to be used for a sorting dropdown control in a Power Apps canvas screen. The collection contains options for sorting data by different columns (like “State”, “Friend Name”, and “Last Updated”), as well as an option for ‘No sort’. The DisplayColumn values are what will be shown to the user in the dropdown, while the ColumnName values probably correspond to the actual column names in the data source that the sorting will be applied to.
Happy #low-code learning
Dr. Amit Puri, Advisor and Consultant, Strengthening Digital Experiences, Modernize Cloud Journey with AI-Driven Transformation!
 
  
        
          
        