I am having fits with lightning aura iteration, it doesn't do anything just puts in a blank row, no errors .Having zero luck here is my lightning component


 <table class="slds-table slds-table--bordered slds-table--cell-buffer">

                            <tr class="slds-text-title--caps">
                            <th scope ="col">
                                <div class="slds-truncate" title="Cart">Cart</div>
                            <th scope="col">
                                <div class="slds-truncate" title="QT">QT</div>
                            <th scope="col">
                                <div class="slds-truncate" title=""></div>

                            <aura:iteration items="{!v.orderItemList}" var="ct">

                                <th scope="row" data-label="Cart">
                                    <div class="slds-truncate" title="{!ct.Description__c}">{!ct.Description__c }</div>
                                <td data-label="QTY">
                                    <div class="slds-truncate" title="{!ct.Quantity__c}">{!ct.Quantity__c}</div>
                                <td data-label="">
                                    <div class="slds-truncate" title="{!ct.Price__c}">{!ct.Price__c}</div>

Here is the JS:

    doInit : function(component, event, helper) {
        var action = component.get("c.getOrder");



            var state = response.getState();
            if(state === "SUCCESS"){




    sendE : function(component, event, helper) {

        var email = component.get("v.order.Email__c");
        var subject = component.get("v.order.Subject__c");
        var action2 = component.get("c.sendEmail");
        var getallitems = component.get("c.orderItem")['ct'];
        var ItemList =[];

        for (var key in getallitems){
           ItemList.push(key+ '=' +getallitems[key]); 
        component.set("v.ItemList", orderItemList);



            var state = res.getState();
            if(state === "SUCCESS"){






 public  static Line__c orderItem {get;set;}
    public static Line__c getOrderLines(string recordId) {
     orderItem = [select Id,Quantity__c,Price__c,Price__c,
                 from Line__c where Order__c=:recordId];
        system.debug('Order rows'+orderItem);
        return orderItem;   
  • 1
    Your code has a ton of problems with it, so much I can barely guess its intent. You may want to start over, and try building a list all by itself as a starting point. – sfdcfox Jan 22 '18 at 22:14
  • I am actually trying to print the table with Cart, Quantity, Price. The Cart = Description, QT = Quantity__c and Price is named blank but APi is Price__c. I am able to get the contents printed in the console when the changed var getallitems = component.get("v.response")['ct']; to get the component values from controller. But I am unable to print on UI – user5432 Jan 22 '18 at 22:24
  • 2
    Yeah, I'm not sure how you'd see anything from component.get("v.response") because you never set it anywhere. Your variable and attribute names are a mess. – sfdcfox Jan 22 '18 at 22:46
  • I just updated the code. My bad, I pasted the wrong code initially – user5432 Jan 22 '18 at 22:56
  • 1
    v.List is undefined I'm pretty sure. Try creating a SSCCE (sscce.org). So that we can help you with your problem more easily, instead of you just dumping all your code here. – Aequitas Jan 22 '18 at 23:08

As sfdcfox mentioned, check your variable names;

You have component.set("v.ItemList", orderItemList); but your variable you are iterating is called <aura:iteration items="{!v.orderItemList}" var="ct"> are these ItemList and orderItemList meant to be the same?

I have created a basic example for you:

Lightning Component:

<aura:attribute name="stringArray" type="String[]" default="a,b" />
<aura:handler name="init" value="{!this}" action="{!c.init}"/>

<aura:iteration items="{!v.stringArray}" var="ct">

Javascript controller:

    init : function(component, event, helper) {
        let stringArray = component.get("v.stringArray");
        component.set("v.stringArray", stringArray);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.