+ Start a Discussion
sandeep@Salesforcesandeep@Salesforce 

How to identify which field got changed in table in Lightning component

<td>
                                <ui:inputcheckbox updateOn="change" change="{!c.SaveChanges}" text="{!item.Id}" value="{!item.CSopke1__Complete__c}"/>
                            </td>
                            <td>
                                <ui:inputDate  updateOn="change" change="{!c.searchChange}" value="{!item.CSopke1__Date__c}" displayDatePicker="true" />
                            </td>
                            <td>
                                <ui:inputText updateOn="change" change="{!c.searchChange}" value="{!item.CSopke1__Notes__c}"/>
                            </td>
Helper.js
SaveChanegHelper: function (cmp, event, helper) {
        var action = cmp.get('c.updateProcess');
        var processId = event.getSource().get("v.text");
        var iscompleted = event.getSource().get('v.value');
        var FieldLabel = ???
how I can get to know which field was changed so that I need to pass this fieldApi to further Apex controller toupdate record accordingly.
 
Abhishek Raj 23Abhishek Raj 23

Hi Sandeep

You can try this 
<lightning:button aura:id="button1" name="buttonname1" label="Click me" onclick="{!c.nameThatButton}"/>

event.getSource().get("v.name")

or you can also identify using aura Id

event.getSource().getLocalId()

sandeep@Salesforcesandeep@Salesforce
Thanks but I want to implement for ui:input tags not button. and also ny ui:input tags are in loop so aura id would be same for all tags at each row of table.
CloudalyzeCloudalyze
Hi Sandeep,
 
You have to register a change event handler on change of that field:
 
<aura:attribute name="listPrice" type="Integer" default="0"/>
<aura:handler name="change" value="{!v.CSopkeComplete}" action="{!c.updateListPrice}"/>
 
<ui:inputcheckbox updateOn="change" change="{!c.SaveChanges}" text="{!item.Id}" value="{!v.CSopkeComplete}"/>
 
And bind the value in the "CSopkeComplete" attribute in  its related field in controller