We’re rewarding the question askers & reputations are being recalculated! Read more.
17

There's a handful of ways, but the most robust would probably be to see if it's not(empty(...)): <aura:if isTrue="{!not(empty(v.opportunityList))}"> ... This will suppress rendering if the list is empty, or null, or undefined...


6

It definitely seems like a bug in the framework. I don't have any explanation as to why it happens, but I have found it helpful in these cases to "reset" the iteration items before setting them again. In other words, your sortItems function would become sortItems: function(component, event, helper) { var items = component.get('v.items'); var ...


6

Yes, you can nest iterators "infinitely" (up to some really large maximum); it looks like you had an unused value provider name prod in your code. Here's a revised, Short, Self Contained, Correct (Compilable), Example: <aura:application > <aura:attribute name="object" type="List" default="[ { 'Sub': [ ...


6

in your second iteration, use {!account.Contacts} instead of {!v.account.Contacts} <aura:iteration items="{!account.Contacts}" var="contact">


6

Is it possible at all? No. Are Standard Components extensible at all? No. Even if it would be possible, is extension a good idea? It'd be potentially useful, but we can't. Slow and async rendering You shouldn't be using tables. It's a shame that they actually allow it, because tables are not used anywhere in Lightning at all....


5

This kind of question had been asked several times so there are couple answers already, that you might find here: Can I use var[i]? Nope! Are there alternative ways to achieve this? Yes: Create a component wrapping the indexVar in an attribute Bind it to an attribute to pass it to the controller Pass it in using html data-attributes In your case I would ...


5

aura:id must be a literal value. As such, you can't use an expression in aura:id (it will be treated as literal text). Instead, you can use the element's id via document.getElementById: var selectedItemNew = document.getElementById(oppId);


5

I do not think class attribute should be used to store index. Instead we can use name in Lightning:input to do so. <aura:iteration items="{!v.values2}" var="value" indexVar="index"> <lightning:input type="text" name="{!index}" value="{!value}" label="Lightning Input" onchange="{!c.update3}"/> </aura:iteration> In js update3 :...


5

lightning:layout is responsive, so you could do something like so: <lightning:layout horizontalAlign="space" verticalAlign="center" multipleRows="true"> <aura:iteration items="{!v.theList}" var="v"> <lightning:layoutItem flexibility="auto" size="12" smallDeviceSize="6" mediumDeviceSize="6" largeDeviceSize="6"> {!v....


5

You cannot do this in salesforce lightning - Aura or LWC. Below are the options that works in salesforce lightning Aura Option 1: Have filtered logic in Javascript and use it in Component. This is preferred. CONTROLLER: let myFullObject = { myList: [...], }; myFullObject.myFilteredList = myFullObject.myList.filter(element => ...); component.set("v....


4

This is similar to a previous post. Look at the answer by our team member JF Paradis which throws some light about why event.target is not returning what you expect it to return. This will be fixed in the Summer'18 release. Please bare with the workaround till such time. In your case, <aura:iteration items="{!v.values2}" var="value" indexVar="index"> ...


4

Well Aura:iteration does not support map. Thus you to write your own parser which will convert the Map into a list of custom javascript object that can be iterated by aura: iteration. Assuming this is the response from the Apex controller. { a0E0k000003aEKUEA2= { Field_10__c=test1, Field_1__c=test2, Field_2__c=test3, ...


4

First problem is that we cannot use expression while assigning aura:id. Aura:id need to be static. so your first change is <a href="javascript:void(0);" role="menuitem" tabindex="-1" id="{!opp.Id}" onclick="{!c.openItemFromMenu}" aura:id="link"> in js you can do openItemFromMenu: function(component, event, helper) { // get the id from ...


4

You'll want to look at this answer regarding force:recordData performance, which lightning:recordViewForm depends on. Basically, doing this is going to generate a ton of traffic and perform very poorly if you're dealing with more than about six records. So, if you expect to have only a handful of records, knock yourself out and use the lightning:record* ...


3

This is a simple list that is not bound to any particular data. You need to bind it to the value it should represent: <lightning:select aura:id="selectId" value="{!account.Former_Reason__c}" name="FormerReason" label="Select a Former Reason:" > Without this binding, you won't get the result you expect. I also suspect that you do not ...


3

This could depend on a lot of things. For example, if your <aura:iteration> is looping over data that you're retrieving via an Apex controller, then the first time it is rendered there will be no components because it hasn't got the data from the server yet. One of the later renderings will include the data. As a general rule, you would be better ...


3

If your Apex class returns the Object in String format, then You Just do JSON.parse("Your_return_String") to get as an Object. EDIT: You have not set Attribute value to 'newassets'.component.set('v.newassets') Example code working fine to me. Component: <aura:component > <aura:attribute name="obj" type="Map"/> <aura:handler name="...


3

You either want to use an aura:method for this or pass an attribute. I suggest that you read the Lightning Inter-Component Communication Patterns blog post to get an overview of the different communication means that are available to you.


3

When you're using normal HTML, you have a lot of flexibility in what you do with this. One solution not involving the use of id is to set a data attribute on the span: <aura:component> <aura:attribute name="numberList" type="Object[]" access="private"/> <aura:iteration items="{!v.numberList}" var="obj"> <span data-num="{!...


3

Fortuitous timing. We think this was just addressed in a change in framework last week. Change here https://github.com/forcedotcom/aura/commit/b76df7cc31e9bb69425f0a41d4f748ceb6978631


3

After your callback function returns where you load the records from the database, just loop through the result records and create new on-the-fly copies of the properties, e.g. record.__backupFirstName = record.FirstName; Now in your aura:if just check against the backup value instead of the field itself. Note that I've used the leading underscores to ...


3

You're on the right track, just missing some pieces to keep moving forward. You'll want to reference an apex controller which helps you with server side actions and surfaces the results to your lightning component. I am using the Account object in my example, in your case you would replace this with your custom object. Create a class(ie appController.apxc)...


3

Your problem is elsewhere in code you've omitted. Here's a self-contained example of comparing the current iterator to a specified value: <aura:application > <aura:attribute name="items" type="List" default="[1,2,3]" /> <aura:attribute name="current" type="Integer" default="2" /> <aura:iteration items="{!v.items}" var="item"...


3

Your thesis is slightly mistaken. Querying Task.Description in SOQL certainly does return line breaks, but they are suppressed in many contexts where you might look for them. You can demonstrate this by doing the following in Anonymous Apex, assuming you have Email-type Tasks present: List<Task> ts = [SELECT Description FROM Task WHERE Subject LIKE '...


3

notequals(ofc.agentName, ' ') compares the value to a single space character, ' '. To check if the value is empty, use the empty() function: !empty(ofc.agentName) This will evaluate to true if the value is anything other than undefined, null, the empty array, and the empty string. (Note that it doesn't check for strings composed only of whitespace, though)....


3

There is a bug in lightning aura conditional rendering aura:if. If you unrender and rerender immediately (i.e., When isTrue condition becomes false and immediately true) then the components do not get unrendered properly. So, from next transaction onwards component.find will be returning an array in which the first element (0 index) will always be the one ...


2

I would expect the code to look like this: var comment = component.get("v.AddCommList")[index].Comment__c; component.set('v.commentTooltip', comment.substr(0, 250)); The attribute holds the array, so once that is got you can index into it to get hold of a specific row. The row corresponds to an SObject and has a property available called Comment__c.


2

We can use the event source to identify which element was updated. This requires iterating over the elements to determine which element was updated. Here's the revised version: <aura:application extends="force:slds"> <aura:attribute name="message2" type="String" /> <aura:attribute name="values2" type="List" default="['','']" /> ...


2

I'm not quite sure if this is a perfect solution but it works. As we can't give dynamic Id but we can give dynamic class name. So I pass dynamic value in class attribute. And then using the onchange event call the controller and get the index. <aura:iteration items="{!v.values2}" var="value" indexVar="index"> <div data-index="{!index}" > ...


2

I don't think this is appropriate way to do so in lightning. One way to do say by firing a event from inner component whenever the value changes in inner component. You can fire event with both value and index and store that information in outer component. Another way to do so is by using double binding principle of lightning. <aura:if isTrue="{!v....


Only top voted, non community-wiki answers of a minimum length are eligible