• NickDzitars
  • NEWBIE
  • 0 Points
  • Member since 2017
  • Big River Technologies Inc.

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
I am creating a generic list component that takes in an object type, and a list of fields that it wants to display. I am looping through each of the items and building a table, but when it comes to outputting the different fields, I am at a bit of a roadblock for doing it dynamically. Here is the relevant component code: 
<aura:component description="ObjectList" controller="ObjectListController">
    <aura:attribute name="objectName" type="String" default="" />
    <aura:attribute name="objectFieldsString" type="String" default="Id,Name" />
    <aura:attribute name="objectFields" type="List" />
    <aura:attribute name="items" type="List" />

    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />

    <table>
        <thead>
        <tr>
            <aura:iteration items="{!v.objectFields}" var="fieldName">
                    <th scope="col"><div class="slds-truncate">{!fieldName}</div></th>
            </aura:iteration>
        </tr>
        </thead>
        <tbody>
        <aura:iteration items="{!v.items}" var="item">
            <tr>
                <aura:iteration items="{!v.objectFields}" var="field">
                        <td>
                                {!item.field}
                        </td>
                </aura:iteration>
            </tr>
        </aura:iteration>
        </tbody>
    </table>
</aura:component>

In the aura:iteration in the tbody, I am trying to cycle through the different field names, and then grab those fields from the item, but it doesn't seem like lightning supports it. For example if objectFields contained an array of strings containing ["Id","Name"], I want to then grab item.Id and item.Name and display them in the table. But using {!item.field} or anything similar does not seem to work.

Could anyone provide me with the proper syntax if this is possible, or a possible workaround to get something like this to work?
Hi All,

I need help in resolving the error. I have declared a attribute name="flag" and doing some condition check and then setting the attribute value to
 something inside if.But i am getting the following error.
Failed to save undefined: The attribute "flag" was not found on the COMPONENT markup://aura:if: Source​
<aura:attribute name="flag" default="0"/>
<div class="slds">  
        <div class="slds-container--center slds-container--small slds-container--medium">
              <aura:iteration items="{!v.ZenObjsnew}" var="zenobjsnew" aura:id="iter">
            <div class="slds-grid slds-wrap">
              <aura:set attribute="flag" value="0"/>
                       <aura:if istrue="{!lessthan(v.flag,2)}">
                <div class="slds-size--12-of-12 slds-small-size--6-of-6 slds-medium-size--6-of-12 slds-large-size--6-of-12 blue-bg ">
                    <div class="slds-size--1-of-2">
                    <div class="slds-grid slds-wrap content-box">
                        <div class="slds-size--12-of-12 slds-medium-size--3-of-12">
                            <img src="{!v.imagepath1}" alt="{!v.imagetext1}"/>
                        </div>
                        
                        <div class="slds-size--12-of-12 slds-medium-size--9-of-12">
                           
                            <h4 class="liheading"> 
                                
                               <div>
                                <a href="{!v.linkpath1}">
                                   {!zenobjsnew.ZenLms_Name_del__c}
                                </a>
                                </div> 
                               
                            </h4>
                           
                            <p class="text-limit">{!v.linktext1}
                            </p>
                            <p class="language  spacer">Chinese 
                                        <a href="javascript:void(0)">????
                                        </a> | Korean 
                                        <a href="javascript:void(0)">???
                                        </a> | French 
                                        <a href="javascript:void(0)">Français
                                        </a> | Japanese 
                                        <a href="javascript:void(0)">???
                                        </a>
                              </p>
                            
                        </div>
                        </div>   
                </div>
                </div>
                <aura:set attribute="flag" value="{!add(v.flag,1)}"/>    
                </aura:if>
                </div>  
            </aura:iteration>
              </div>          
            </div>

Thanks in Advance,
Deepak.
 
Hi,
In my custom lightning component I've added i lightning standard icon inside a slds box, the slds box is of blue color and the lightning icon is of orange color. I am unable to sync both colors, that is make icon color as blue(same as the slds box)

<div class="slds-box slds-theme--alt-inverse slds-text-align--right">
         <div class="slds-text-align--left">
              <lightning:icon iconName="standard:lead" size="small"  />
          </div>  
  </div>

Any suggestions?
I need to save the values to the custom object. But when I upsert I get error that it is a null list.
My controller:
CreateExpense: function(component, event, helper) {
         
            alert("Hi");
       var Expense=component.get("v.Expense");
        component.set("v.Expense",Expense);
alert(Expense);   
      helper.CreateExpense(component,Expense);
    }
Helper:
({
    CreateExpense : function(component,expenses){         
        alert("upsert");       
       this.upsertExpense(component, expenses, function(a) {
           var exp = component.get("v.exp");
           exp.push(a.getReturnValue());
            component.set("v.exp", exp);
            });
    },
         upsertExpense : function(component, expenses, callback) {
           var action = component.get("c.saveexp");
        action.setParams({ 
            "expense":expenses
            
        });
     if (callback) {
action.setCallback(this, callback);
     }
  
$A.enqueueAction(action);
}      
    
})
Apex controller:
Public with sharing class ExpenseController {
     @AuraEnabled
    public static expense__c saveexp(expense__c expenses)
    { 
        
       upsert expenses;
        system.debug('@@@@@@@@@@@@'+expenses);
        return expenses;
    }

}
Thanks