You need to sign in to do that
Don't have an account?
brahmanaidu
How to update the field values using checkbox in salesforce Lightning
<aura:component controller="ListAccounts">
<aura:attribute name="accounts" type="List" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:attribute name="accList" type="list"/>
<!--
Use a data table from the Lightning Design System:
https://www.lightningdesignsystem.com/components/data-tables/
-->
<table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout">
<thead>
<tr class="slds-text-heading--label">
<th scope="col"><div class="slds-truncate" title="Select">Select</div></th>
<th scope="col"><div class="slds-truncate" title="ID">ID</div></th>
<th scope="col"><div class="slds-truncate" title="Name">Name</div></th>
<th scope="col"><div class="slds-truncate" title="Site">Site</div></th>
</tr>
</thead>
<tbody>
<!-- Use the Apex model and controller to fetch server side data -->
<aura:iteration items="{!v.accounts}" var="account">
<tr>
<th scope="row">
<ui:inputCheckbox />
</th>
<th scope="row"><div class="slds-truncate" title="{!account.Id}">{!account.Id}</div></th>
<td><div class="slds-truncate" title="{!account.Name}">{!account.Name}</div></td>
<td><div class="slds-truncate" title="{!account.Site}">{!account.Site}</div></td>
<td>
</td>
</tr>
</aura:iteration>
<ui:button label="Aprove" press="{!c.approve}"/>
</tbody>
</table>
</aura:component>
({
// Fetch the accounts from the Apex controller
doInit: function(component,event,helper) {
var action = component.get('c.getAccounts');
// Set up the callback
var self = this;
action.setCallback(this, function(actionResult) {
component.set('v.accounts', actionResult.getReturnValue());
});
$A.enqueueAction(action);
},
approve: function(component,event,helper) {
var a = component.get('c.getApproved');
console.log('checking the status');
a.setCallback(this, function(response) {
component.set('v.accList', response.getReturnValue());
});
$A.enqueueAction(a);
},
})
public class ListAccounts {
@AuraEnabled
public static List<Account> getAccounts() {
return [SELECT Id, name,site from Account Limit 6];
}
@AuraEnabled
public static void getApproved(){
List<Account> accs=[select Id,Name,Site from Account];
for(Account a:accs){
a.Site='Approved';
}
}
}
<aura:attribute name="accounts" type="List" />
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:attribute name="accList" type="list"/>
<!--
Use a data table from the Lightning Design System:
https://www.lightningdesignsystem.com/components/data-tables/
-->
<table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout">
<thead>
<tr class="slds-text-heading--label">
<th scope="col"><div class="slds-truncate" title="Select">Select</div></th>
<th scope="col"><div class="slds-truncate" title="ID">ID</div></th>
<th scope="col"><div class="slds-truncate" title="Name">Name</div></th>
<th scope="col"><div class="slds-truncate" title="Site">Site</div></th>
</tr>
</thead>
<tbody>
<!-- Use the Apex model and controller to fetch server side data -->
<aura:iteration items="{!v.accounts}" var="account">
<tr>
<th scope="row">
<ui:inputCheckbox />
</th>
<th scope="row"><div class="slds-truncate" title="{!account.Id}">{!account.Id}</div></th>
<td><div class="slds-truncate" title="{!account.Name}">{!account.Name}</div></td>
<td><div class="slds-truncate" title="{!account.Site}">{!account.Site}</div></td>
<td>
</td>
</tr>
</aura:iteration>
<ui:button label="Aprove" press="{!c.approve}"/>
</tbody>
</table>
</aura:component>
({
// Fetch the accounts from the Apex controller
doInit: function(component,event,helper) {
var action = component.get('c.getAccounts');
// Set up the callback
var self = this;
action.setCallback(this, function(actionResult) {
component.set('v.accounts', actionResult.getReturnValue());
});
$A.enqueueAction(action);
},
approve: function(component,event,helper) {
var a = component.get('c.getApproved');
console.log('checking the status');
a.setCallback(this, function(response) {
component.set('v.accList', response.getReturnValue());
});
$A.enqueueAction(a);
},
})
public class ListAccounts {
@AuraEnabled
public static List<Account> getAccounts() {
return [SELECT Id, name,site from Account Limit 6];
}
@AuraEnabled
public static void getApproved(){
List<Account> accs=[select Id,Name,Site from Account];
for(Account a:accs){
a.Site='Approved';
}
}
}
apex class lightning component :
javaScript controller : helper js
test app : Thanks
let us know if it helps you
sfdcMonkey.com
for refrence : http://sfdcmonkey.com/2017/02/23/delete-multiple-records-using-checkbox-lightning-component/
All Answers
apex class lightning component :
javaScript controller : helper js
test app : Thanks
let us know if it helps you
sfdcMonkey.com
for refrence : http://sfdcmonkey.com/2017/02/23/delete-multiple-records-using-checkbox-lightning-component/
i am refering to this thread, i am stuck
I am working on a Education project, I have four custom objects, Student__c, Class__c, course__c,Attandence__c
The first part is working fine, That is, (Snapshot 1) when I click on Update Attendance button, a check box is checked in a student object (Snapshot 2) and it Is also checked in child object called Attendance__c and Related Record Gets created (Snapshot 3)
Now I want to put another button called as Update Absentee button, when I click this button, Checkbox should get updated in the Student object named (Check for Absentee__c) and related record should get created and it should not get updated in attendance custom object,
Can anyone please help regarding this issue