You need to sign in to do that
Don't have an account?

Add "All" value to Lightning:Select field
I have a component with a few Lightning:Select fields that I'm using to filter the page. I am populating the values using an apex class to pull the values for all existing records. See below for snipet of the apex class.
Thanks!!
Fred
//get a deduped list of group numbers @AuraEnabled public static List<group_structure__c> getgroupnumbers() { List<group_structure__c> groupstructures = [SELECT Id, group_number__c FROM group_structure__c]; //added to pull in group numbers List<group_structure__c> groupnumbers = new List<group_structure__c>(); Set<String> fgroupnumbers = New Set<String>(); for (group_structure__c gs : groupstructures){ if (fgroupnumbers.Contains(gs.group_number__c) == FALSE){ fgroupnumbers.add(gs.group_number__c); groupnumbers.add(gs); } groupnumbers.add('all'); system.debug('group numbers' + groupnumbers); } return groupnumbers; }I'm trying to add a value of "All" which would be the default value. In my client side controller I will then filter the overall list based on these values. I can't figure out how to add an "All" value. I tried to just add it in the component, however, no value gets associated to selected All when using this method (see below)
<lightning:layoutItem padding="around-small"> <!-- Create a dropdown menu with options for Group Number--> <lightning:select aura:id="selectGroupNum" label="GroupNum" name="sourceGroupNum" onchange="{!c.handleSelect}"> <option value="">All</option> <aura:iteration items="{!v.groupnumbers}" var="gs"> <option value="{!gs.id}">{!gs.Group_Number__c}</option> </aura:iteration> </lightning:select> </lightning:layoutItem>Any help would be greatly appreciated!!!
Thanks!!
Fred
Try this pls
Here is the component:
Here is the helper:
Here is the Apex controller: