You need to sign in to do that
Don't have an account?
Anand TripathiSBI
I am trying to create filter on lead (like lead status,Created date) as well as a delete button which select all the leads and delete using Aura Components. But Not able to do this Can you help me. Code is given below.
I want to dispaly a buttuon for search where I can select lead status. If I select open then all the open leads will displayed.
//Component//
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" controller="LeadSearchFilter" access="global" >
<aura:attribute name="accs" type="Account[]"></aura:attribute>
<aura:handler name="init" value="{!this}" action="{!c.showAllAccounts}"></aura:handler>
<!--<lightning:input label="Search Account" placeholder="Search account by name or rating or industry" aura:id="txt1" onchange="{!c.showFilterAccount}"></lightning:input>-->
<lightning:select aura:id="select" name="select" label="Select Lead" onchange="{! c.showAllAccounts }">
<option value="">choose one...</option>
<option value="apple">status</option>
<option value="pumpkin">Name</option>
<option value="pumpkin">Lead Stage</option>
</lightning:select>
<br/><br/>
<table border="1">
<tr>
<th>Name</th>
<th>Company</th>
<th>Status</th>
<th>Email</th>
</tr>
<aura:iteration items="{!v.accs}" var="acc">
<tr>
<td>{!acc.Name}</td>
<td>{!acc.Company}</td>
<td>{!acc.Status}</td>
<td>{!acc.Email}</td>
</tr>
</aura:iteration>
</table>
</aura:component>
//Apex Class//
public class LeadSearchFilter {
@AuraEnabled
public static List<Lead> showAllAccs()
{
return [select name , company ,Email,Status from Lead];
}
@AuraEnabled
public static List<Lead> showFilterAccs(string acName)
{
return [select name , company , Email,status from Lead
where name like :'%'+acName+'%' or status like :'%'+acName+'%'];
}
}
//Controller//
({
showAllAccounts : function(component, event, helper) {
var action = component.get("c.showAllAccs");
action.setCallback(this,function(response){
var state = response.getState();
if(state=='SUCCESS')
{
component.set("v.accs",response.getReturnValue());
}
else{
alert('errror '+state);
}
});
$A.enqueueAction(action);
},
showFilterAccount: function(component, event, helper) {
var action = component.get("c.showFilterAccs");
var n = component.find("txt1").get("v.value");
action.setParams({"acName":n});
action.setCallback(this,function(response){
var state = response.getState();
if(state=='SUCCESS')
{
component.set("v.accs",response.getReturnValue());
}
else{
alert('errror '+state);
}
});
$A.enqueueAction(action);
}
})
//Component//
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" controller="LeadSearchFilter" access="global" >
<aura:attribute name="accs" type="Account[]"></aura:attribute>
<aura:handler name="init" value="{!this}" action="{!c.showAllAccounts}"></aura:handler>
<!--<lightning:input label="Search Account" placeholder="Search account by name or rating or industry" aura:id="txt1" onchange="{!c.showFilterAccount}"></lightning:input>-->
<lightning:select aura:id="select" name="select" label="Select Lead" onchange="{! c.showAllAccounts }">
<option value="">choose one...</option>
<option value="apple">status</option>
<option value="pumpkin">Name</option>
<option value="pumpkin">Lead Stage</option>
</lightning:select>
<br/><br/>
<table border="1">
<tr>
<th>Name</th>
<th>Company</th>
<th>Status</th>
<th>Email</th>
</tr>
<aura:iteration items="{!v.accs}" var="acc">
<tr>
<td>{!acc.Name}</td>
<td>{!acc.Company}</td>
<td>{!acc.Status}</td>
<td>{!acc.Email}</td>
</tr>
</aura:iteration>
</table>
</aura:component>
//Apex Class//
public class LeadSearchFilter {
@AuraEnabled
public static List<Lead> showAllAccs()
{
return [select name , company ,Email,Status from Lead];
}
@AuraEnabled
public static List<Lead> showFilterAccs(string acName)
{
return [select name , company , Email,status from Lead
where name like :'%'+acName+'%' or status like :'%'+acName+'%'];
}
}
//Controller//
({
showAllAccounts : function(component, event, helper) {
var action = component.get("c.showAllAccs");
action.setCallback(this,function(response){
var state = response.getState();
if(state=='SUCCESS')
{
component.set("v.accs",response.getReturnValue());
}
else{
alert('errror '+state);
}
});
$A.enqueueAction(action);
},
showFilterAccount: function(component, event, helper) {
var action = component.get("c.showFilterAccs");
var n = component.find("txt1").get("v.value");
action.setParams({"acName":n});
action.setCallback(this,function(response){
var state = response.getState();
if(state=='SUCCESS')
{
component.set("v.accs",response.getReturnValue());
}
else{
alert('errror '+state);
}
});
$A.enqueueAction(action);
}
})