You need to sign in to do that
Don't have an account?
Lightning actionResult.getReturnvalue
Hi All,
I am facing an issue in which i am getting lists of lists from Controller in lightning and want to set into array because i need each index of element from that list of lists.Here is the code.
I am facing an issue in which i am getting lists of lists from Controller in lightning and want to set into array because i need each index of element from that list of lists.Here is the code.
Public static list<List<ZenObject__c>> getZenObjsOdd(){ Integer colcount=getColumnsCount(); Integer index=0,i; list<list<ZenObject__c>> lst=new list<list<ZenObject__c>>(); List<ZenObject__c> ZenobjsOdd=new List<ZenObject__c>(); List<ZenObject__c> Zenobjs=[Select ZenLms_Name_del__c,ZenLms_SubText__c,ZenImage__c from ZenObject__c order by createddate]; integer listsize=Zenobjs.size(); for(integer col=1;col<=(listsize/colcount);col++){ for(i=index;i<(index+colcount);i++){ ZenobjsOdd.add(Zenobjs[i]); } index=i; lst.add(ZenobjsOdd); } if(math.mod(listsize,colcount)!=0) { for(integer j=index;j<index+(math.mod(listsize,colcount));j++){ ZenobjsOdd.add(Zenobjs[j]); lst.add(ZenobjsOdd); } } return lst; } //JS controller getZenObjsOdd : function (component){ var action = component.get("c.getZenObjsOdd"); var items[]; action.setCallback(this, function(actionResult){ var state = actionResult.getState(); if (component.isValid() && state === "SUCCESS"){ items.push(JSON.stringify(actionResult.getReturnValue())); console.log('hihih ' +items); component.set("v.ZenObjsOdd",items); } }); $A.enqueueAction(action); },
From the code it is clear that i am pushing actionResult.getReturnValue() in array.But there is something wrong here.Anyhelp would be appreciated,
Thanks,
Deepak.
However - I've done something close to this in lightning - and in that situation - I used a sub-class. In my situation - I had a sub-class like this...
That's what was returned.
The .js controller was the same - ( component.set("v.allCourses", response.getReturnValue()); )
The markup was like this...
<aura:iteration items="{!v.allCourses.activeCourses}" var="course">