728x90
일을하다가 보니, 당연히 될 것 같은데 안되는 것 중 하나
상황 1. Aura:id 값을 아래와 같이 동적 할당
상황 2 Component.find('동적변수')하여 가져오고자 함
구글을 서치한 결과 아래와 같은 코드는 사용이 불가능 하다고 한다
<aura:iteration indexVar="index" items="{!v.actions}" var="obj">
<tr>
<td>
<ui:inputCheckbox aura:id="{!'index' + index}" change="{!c.changeCheckbox}" >
{!'index' + index}
</ui:inputCheckbox>
</td>
<td>
{!obj.Summary__c}
</td>
<td>
{!obj.Due_Date__c}
</td>
<td>
{!obj.User__c}
</td>
</tr>
</aura:iteration>
어떻게 해결할지는 각자의 방법이지만
나는 아이디를 일괄적으로 주고 해당 id에 들어가있는 Name="{! index + index }"에 이렇게 동적 변수를 할당 후
컨트롤러단에서 아래와 같이 가져왔다
1) test.cmp
<aura:iteration indexVar="index" items="{!v.actions}" var="obj">
<tr>
<td>
<ui:inputCheckbox aura:id="ETC" Name="{!index + index}" change="{!c.changeCheckbox}" >
{!'index' + index}
</ui:inputCheckbox>
</td>
<td>
{!obj.Summary__c}
</td>
<td>
{!obj.Due_Date__c}
</td>
<td>
{!obj.User__c}
</td>
</tr>
</aura:iteration>
2)cmpController.js
saveContent : function(component, event, helper) {
const contentData = [];
const ETCs = component.find("ETC");
ETCs.forEach(function(etc){
const fieldName = etc.get("v.name");
const valueData = etc.get("v.value");
contentData.push({
fieldName : fieldName,
value : valueData
});
});
}
출처:
https://developer.salesforce.com/forums/?id=906F00000005G4IIAU
728x90
'개발' 카테고리의 다른 글
[Salesforce] Case, Account등 앱 관리자에서 검색이 안될 때 (1) | 2022.09.21 |
---|---|
[Salesforce] 프로필별 오브젝트 권한 조회하기 (0) | 2022.09.13 |
[python] 명령어 pip에서 pip3로 변경하기 (0) | 2022.08.09 |
[Python] PDF -> 텍스트 추출 비교(PyPDF2, tika) (0) | 2022.08.09 |
[Python] 맥(인텔) pip : command not found (0) | 2022.08.04 |