You need to sign in to do that
Don't have an account?
Dharmendra Kumar 60
How to perform rowaction using iteration component
I am trying to build a custom component using <aura:iteration> and add the rowaction "Add" and "View" ,which will take the user to "Add New Campaign member" and 'View related Campaign Member " respectively for each campaign record. Something like this -
Server Side Controller :-
public class MarketingCampaignController {
@AuraEnabled
public static List<Campaign> CampaignsSOQL(string searchString) {
String queryString = 'Select id, name,type,status from Campaign ';
if(searchString!=null && searchString!=''){
searchString = '%'+string.escapeSingleQuotes(searchString)+'%';
queryString = queryString+ 'where Name Like:searchString';
}
queryString = queryString + ' Limit 10000';
List<Campaign> campList = database.query(queryString);
return campList;
}
}
Component :-
<aura:component controller="MarketingCampaignController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="campList" type="Object"/>
<aura:attribute name="accSearchValue" type="String" default=""/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<div class="slds-card">
<div class="slds-card__header slds-grid">
<header class="slds-media slds-media_center slds-has-flexi-truncate">
<div class="slds-media__figure">
<lightning:Icon iconName="standard:account" size="Medium"
class="slds-icon slds-input__icon slds-input__icon_right " />
</div>
<div class="slds-media__body">
<h2><span class="slds-text-heading_medium">Marketing Campaigns</span></h2>
</div>
</header>
<div class="slds-no-flex">
<div class="slds-form-element__control slds-input-has-icon slds-input-has-icon_right">
<lightning:input value="{!v.accSearchValue}" placeholder="Search" type="text" label="" name="Campaign Search" onchange="{!c.doInit}"/>
</div>
</div>
</div>
<table class="slds-table slds-table_bordered slds-table_cell-buffer">
<thead>
<tr class="slds-text-title_caps">
<th scope="col">
<div class="slds-truncate" title="Name"></div>
</th>
<th scope="col">
<div class="slds-truncate" title="Name"></div>
</th>
<th scope="col">
<div class="slds-truncate" title="Name">Name</div>
</th>
<th scope="col">
<div class="slds-truncate" title="Approver">Type</div>
</th>
<th scope="col">
<div class="slds-truncate" title="Approver">StartDate</div>
</th>
<th scope="col">
<div class="slds-truncate" title="Approver">Status</div>
</th>
</tr>
</thead>
<tbody>
<!--### display all records of searchResult attribute by aura:iteration ###-->
<aura:iteration items="{!v.campList}" var="camp" indexVar="count" >
<tr>
<td>
{!count + 1}
</td>
<td>
<div class="slds-align_absolute-center slds-p-top_small">
<lightning:button variant="success" label="View" title="Brand action" onclick="{!c.view}" />
<lightning:button variant="success" label="Add" title="Brand action" onclick="{!c.Add}" />
</div>
</td>
<td >
<div class="slds-truncate">{!camp.Name}</div>
</td>
<td>
<div class="slds-truncate">{!camp.Type}</div>
</td>
<td >
<div class="slds-truncate">{!camp.StartDate}</div>
</td>
<td>
<div class="slds-truncate">{!camp.Status}</div>
</td>
</tr>
</aura:iteration>
</tbody>
</table>
</div>
<footer class="slds-card__footer"></footer>
</aura:component>
How to implement those Rowaction buttons ? Kindly help.
Server Side Controller :-
public class MarketingCampaignController {
@AuraEnabled
public static List<Campaign> CampaignsSOQL(string searchString) {
String queryString = 'Select id, name,type,status from Campaign ';
if(searchString!=null && searchString!=''){
searchString = '%'+string.escapeSingleQuotes(searchString)+'%';
queryString = queryString+ 'where Name Like:searchString';
}
queryString = queryString + ' Limit 10000';
List<Campaign> campList = database.query(queryString);
return campList;
}
}
Component :-
<aura:component controller="MarketingCampaignController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="campList" type="Object"/>
<aura:attribute name="accSearchValue" type="String" default=""/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<div class="slds-card">
<div class="slds-card__header slds-grid">
<header class="slds-media slds-media_center slds-has-flexi-truncate">
<div class="slds-media__figure">
<lightning:Icon iconName="standard:account" size="Medium"
class="slds-icon slds-input__icon slds-input__icon_right " />
</div>
<div class="slds-media__body">
<h2><span class="slds-text-heading_medium">Marketing Campaigns</span></h2>
</div>
</header>
<div class="slds-no-flex">
<div class="slds-form-element__control slds-input-has-icon slds-input-has-icon_right">
<lightning:input value="{!v.accSearchValue}" placeholder="Search" type="text" label="" name="Campaign Search" onchange="{!c.doInit}"/>
</div>
</div>
</div>
<table class="slds-table slds-table_bordered slds-table_cell-buffer">
<thead>
<tr class="slds-text-title_caps">
<th scope="col">
<div class="slds-truncate" title="Name"></div>
</th>
<th scope="col">
<div class="slds-truncate" title="Name"></div>
</th>
<th scope="col">
<div class="slds-truncate" title="Name">Name</div>
</th>
<th scope="col">
<div class="slds-truncate" title="Approver">Type</div>
</th>
<th scope="col">
<div class="slds-truncate" title="Approver">StartDate</div>
</th>
<th scope="col">
<div class="slds-truncate" title="Approver">Status</div>
</th>
</tr>
</thead>
<tbody>
<!--### display all records of searchResult attribute by aura:iteration ###-->
<aura:iteration items="{!v.campList}" var="camp" indexVar="count" >
<tr>
<td>
{!count + 1}
</td>
<td>
<div class="slds-align_absolute-center slds-p-top_small">
<lightning:button variant="success" label="View" title="Brand action" onclick="{!c.view}" />
<lightning:button variant="success" label="Add" title="Brand action" onclick="{!c.Add}" />
</div>
</td>
<td >
<div class="slds-truncate">{!camp.Name}</div>
</td>
<td>
<div class="slds-truncate">{!camp.Type}</div>
</td>
<td >
<div class="slds-truncate">{!camp.StartDate}</div>
</td>
<td>
<div class="slds-truncate">{!camp.Status}</div>
</td>
</tr>
</aura:iteration>
</tbody>
</table>
</div>
<footer class="slds-card__footer"></footer>
</aura:component>
How to implement those Rowaction buttons ? Kindly help.
And JS
Please refer to this link if need more help http://www.sfdcpoint.com/salesforce/modal-popup-lightning-component-salesforce/
I Hope this solve Your Problem.
Use it to call record from your org using js and apex.
Thanks for your response. I have fixed this issue .
Can we have filtering in Lightning datatable/iteration similar to the filtering capacity in excel ? If you have any idea , please help.
Yes you can add filter in Lightning datatable/itration.Take a look at my code on account object which filter on name and id on click.
Component
Controler
Helper
Apex
You can also do that for Lightning Datatable.Here is a link where you find the code for that and instruction.
http://sfdcmonkey.com/2019/03/06/implement-sorting-salesforce-lightning-datatable/
Hope this help you.
Thanks for your input . This implements sorting capability in the different columns.
I am looking for filtering cabability in Lightning datatable/iteration as we do row filtering by values in excel .Please help you you have any idea.