function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vanitha ManiVanitha Mani 

how to refresh table in lightning component

Hi,
i have a table inside lightning component..aura iteration items comes from another lightning component..when i add the new record then the table should refresh and display the values..can anyone help me with that.
User-added imageUser-added image<div class="slds-m-around_xx-small">
        <div class="slds-align--absolute-left">
        <h1 class="slds-text-heading--small">Below are the 5 most recent work time entries</h1>
            <br/>
        </div>
                </div>
                             
                            <table class="slds-table slds-table_bordered slds-table_cell-buffer">
        <thead>
            <tr class="slds-text-title--caps">
                
                <th scope="col"><div class="slds-truncate" title="Id">S.No</div></th>
               
                <th scope="col"><div class="slds-truncate" title="Work Date">Work Date</div></th>
                <th scope="col"><div class="slds-truncate" title="User">User</div></th>
                <th scope="col"><div class="slds-truncate" title="Minutes">Minutes</div></th>
                <th scope="col"><div class="slds-truncate" title="After Hours">After Hours</div></th>
                <th scope="col"><div class="slds-truncate" title="Reason">Reason</div></th>
                
                
            </tr>
        </thead>          
        <tbody>
    
               <aura:iteration items="{!v.timeList}" var="time" indexVar="sNo"  >
              
                       
             
                   <c:Inlinechildtime single="{!time}"  sNo="{!sNo + 1}"/>
                   
            </aura:iteration>
            </tbody>
            </table>
                            <br/>
                            <br/>
                            <center>
                            <div class="slds-m-around_xx-small">
        <div class="slds-align--absolute-Center">
        <h1 class="slds-text-heading--small">Do you need to add any additional work time?</h1>
            <br/>
            <br>
            </br>
            <br>
            </br>
        </div>
                </div>
                            
                    <button class="slds-button slds-button_success" type ="submit" onclick="{!c.actionhandler2}"  >Yes</button>
                                

                            <button class="slds-button slds-button_destructive" onclick="{!c.handleNext1}">No</button>
                                <br/>
                                <br/>
                                <br/>
                                <br/><br/>
                                <br/>
                                <br/><br/><br/><br/>
                           
            <aura:if isTrue="{!v.seeu}">
 <div role="dialog" aura:id="Modalbox" class="slds-modal slds-fade-in-open ">
               <div class="slds-modal__container">
                   
                   <div class="slds-m-around--xx-large">
                       
        <lightning:card title="Work Time" iconName="custom:custom86" class="slds-p-around_medium">
            <br/>
            <lightning:recordEditForm aura:id="leadCreateForm2"  objectApiName="SVC_Work_Time__c">
                <lightning:messages />
                 
                <lightning:inputField fieldName="Ticket__c" value="{!v.recordId}"></lightning:inputField>
                        <lightning:inputField aura:id="lookup" fieldName="Work_Date__c"></lightning:inputField>
                   
                   
                        <lightning:inputField aura:id="lookup" fieldName="User__c"></lightning:inputField>
               
               
                        <lightning:inputField aura:id="lookup" fieldName="Minutes__c"></lightning:inputField>
                  
                   
                        <lightning:inputField aura:id="lookup" fieldName="After_Hours__c"></lightning:inputField>
                
                          
                        <lightning:inputField aura:id="lookup" fieldName="Reason__c"></lightning:inputField>
                  <br/><br/><br/>
                <center>
                 
                <lightning:button type="submit" label="Save" variant="brand" onclick="{!c.handleOnSubmit}"/>
                    <lightning:button type="submit" label="Save and New"  variant="brand" onclick="{!c.handleOnSubmit2}"/> 
                <lightning:button  label="Close" onclick="{!c.closemodal}" variant="brand"/>
                </center>
            </lightning:recordEditForm>
        </lightning:card>
    </div>
                </div>
            </div>
            <div class="slds-backdrop slds-backdrop--open" aura:id="Modalbackdrop"> 
             </div>
         
          </aura:if>    

how to refresh this table..

thanks 
 
ravi soniravi soni
hi Vanitha,
show me complete html,js and apex file. I will try to fix it.
Thank you
vijay kumar kvijay kumar k
Hi Vanita

Check how you adding new data into timeList.First, get the all data of the list and push new data into a list.

Check below simple snippet 
var timeList = component.get("v.timeList");
///Logic to push new data into list
component.set("v.timeList",timeList);

If the issue still exists share the below points.
1.How new data coming to the lightning component and also for getting new data what action your doing.
2.Js code where you're getting new data and adding it to list

Regards
Vijay
Mayur Gore 10Mayur Gore 10
You need to use splice technique
For reference watch below video from time 35.00
https://www.youtube.com/watch?v=7J21fbbI4Sw&list=PL-JzyFWuCbkKk0c6WqDdFrjev-wD0SndG&index=4&ab_channel=SalesforceTechbook