SHARE
TWEET

Untitled

a guest Feb 19th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <aura:attribute name="LstOfAddedUser" type="List" description="Hold the list of added userUser Data"/>
  2. <aura:attribute name="UserdataList" type="List"/>
  3. <aura:iteration items="{!v.UserdataList}" var="userData" indexVar="i">
  4.     <a onclick="{!c.removeRow}" data-index="{!i}">
  5.         <lightning:icon variant="error" iconName="utility:delete" class="slds-icon slds-icon_small" size="small" alternativeText="icon"/>
  6.         <span class="slds-assistive-text">Delete Icon</span>
  7.     </a>
  8. </aura:iteration>
  9.      
  10. removeRow : function(cmp, event, helper) {                    
  11.  var index = event.target.dataset.index;
  12.     var ListOfUsr=cmp.get("v.LstOfAddedUser");
  13.     ListOfUsr.splice(index, 1);
  14.     //some custom logic below
  15.     var action = cmp.get("c.deleteRow");
  16.     var pageNumber = cmp.get("v.PageNumber");  
  17.     var pageSize = cmp.get("v.pageSize");
  18.     if(ListOfUsr!=null && ListOfUsr!=''){
  19.         action.setParams({
  20.             "selectedIds":JSON.stringify(ListOfUsr.map(thisItem => thisItem.Id)),
  21.             "pageNumber": pageNumber,
  22.             "pageSize": pageSize,
  23.  
  24.         });
  25.         action.setCallback(this, function(response){
  26.             var state = response.getState();
  27.             if(state ==="SUCCESS")
  28.             {
  29.                 var resultData = response.getReturnValue();
  30.                 cmp.set("v.UserdataList", resultData.userdataList);
  31.                 cmp.set("v.PageNumber", resultData.pageNumber);
  32.                 cmp.set("v.TotalRecords", resultData.totalRecords);
  33.                 cmp.set("v.RecordStart", resultData.recordStart);
  34.                 cmp.set("v.RecordEnd", resultData.recordEnd);
  35.                 cmp.set("v.TotalPages", Math.ceil(resultData.totalRecords / pageSize));  
  36.             }  
  37.         });
  38.         $A.enqueueAction(action);
  39.     }
  40. }
  41.      
  42. var index = event.target.dataset.index;
  43.      
  44. <aura:iteration items="{!v.UserdataList}" var="userData" indexVar="i">
  45.     <a onclick="{!c.removeRow}" id="{!userData.id}">
  46.         <lightning:icon variant="error" iconName="utility:delete" class="slds-icon slds-icon_small" size="small" alternativeText="icon"/>
  47.         <span class="slds-assistive-text">Delete Icon</span>
  48.     </a>
  49. </aura:iteration>
  50.      
  51. <aura:iteration items="{!v.UserdataList}" var="userData" indexVar="i">
  52.   <lightning:buttonIcon variant="error"
  53.      iconName="utility:delete"
  54.     class="slds-icon slds-icon_small"
  55.     size="small"
  56.     alternativeText="icon"
  57.     value="{!userData.id}"
  58.     onclick="{!c.removeRow}"/>
  59.   <span class="slds-assistive-text">Delete Icon</span>
  60. </aura:iteration>
  61.      
  62. removeRow : function(cmp, event, helper) {                    
  63.  var id= event.getSource().get('v.value');
  64. //use this id to find relevant record and update your list.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top