You need to sign in to do that
Don't have an account?
Mokshada
How to display related Contacts according to dropdown list
I have one dropdown list for lastname of contacts in my lightning component which have values like all, deshmukh etc and if I select deshmukh from dropdown it should display contacts whose lastname is deshmukh, if it is jail it should display contact whose lastname is jain like that.
code:-
component:-
<aura:component controller="relatedcontactlist" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:attribute name="recordId" type="Id" />
<aura:attribute name="ContactList" type="Contact[]"/>
<aura:attribute name="columns" type="List"/>
<aura:handler name="init" value="{!this}" action="{!c.myAction}" />
<lightning:card iconName="standard:work_capacity_usage" title="Related Contacts">
<lightning:select name="select1" label="Lastnames" required="true">
<option value="1">All</option>
<option value="2">Deshmukh</option>
<option value="3">Pagar</option>
<option value="4">Joshi</option>
<option value="4">Jain</option>
</lightning:select>
<aura:if isTrue="{!not(empty(v.ContactList))}">
<lightning:datatable data="{!v.ContactList }"
columns="{!v.columns }"
keyField="Id"
hideCheckboxColumn="true"/>
<aura:set attribute="else">
<div Style="text-align : center"> " There are no related contacts " </div>
</aura:set>
</aura:if>
</lightning:card>
</aura:component>
controller:-
({
myAction : function(component, event, helper)
{
component.set('v.columns', [
{label: 'First Name', fieldName: 'FirstName', type: 'text' },
{label: 'Last Name', fieldName: 'LastName', type: 'text' }
]);
var ConList = component.get("c.getRelatedList");
ConList.setParams
({
recordId: component.get("v.recordId")
});
ConList.setCallback(this, function(data)
{
component.set("v.ContactList", data.getReturnValue());
});
$A.enqueueAction(ConList);
}
})
apex:-
public class relatedcontactlist {
@AuraEnabled
public static list<Contact> getRelatedList(Id recordId)
{
List<Contact> Conlist = [Select id, name,firstname,lastname from Contact where AccountId=: recordId ];
return Conlist;
}
}
Thanks
code:-
component:-
<aura:component controller="relatedcontactlist" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:attribute name="recordId" type="Id" />
<aura:attribute name="ContactList" type="Contact[]"/>
<aura:attribute name="columns" type="List"/>
<aura:handler name="init" value="{!this}" action="{!c.myAction}" />
<lightning:card iconName="standard:work_capacity_usage" title="Related Contacts">
<lightning:select name="select1" label="Lastnames" required="true">
<option value="1">All</option>
<option value="2">Deshmukh</option>
<option value="3">Pagar</option>
<option value="4">Joshi</option>
<option value="4">Jain</option>
</lightning:select>
<aura:if isTrue="{!not(empty(v.ContactList))}">
<lightning:datatable data="{!v.ContactList }"
columns="{!v.columns }"
keyField="Id"
hideCheckboxColumn="true"/>
<aura:set attribute="else">
<div Style="text-align : center"> " There are no related contacts " </div>
</aura:set>
</aura:if>
</lightning:card>
</aura:component>
controller:-
({
myAction : function(component, event, helper)
{
component.set('v.columns', [
{label: 'First Name', fieldName: 'FirstName', type: 'text' },
{label: 'Last Name', fieldName: 'LastName', type: 'text' }
]);
var ConList = component.get("c.getRelatedList");
ConList.setParams
({
recordId: component.get("v.recordId")
});
ConList.setCallback(this, function(data)
{
component.set("v.ContactList", data.getReturnValue());
});
$A.enqueueAction(ConList);
}
})
apex:-
public class relatedcontactlist {
@AuraEnabled
public static list<Contact> getRelatedList(Id recordId)
{
List<Contact> Conlist = [Select id, name,firstname,lastname from Contact where AccountId=: recordId ];
return Conlist;
}
}
Thanks
Can you confirm what is the issue you are facing in the code. Is the code not working as expected?
Thanks,
can you please guide?
Thanks,
Is there any submit button once value is selected or once value is changes the records should be displayed?
Thanks,