You need to sign in to do that
Don't have an account?
Ab
Select All check box for table and Saving them
Hello,
I have a PageBlockTable, with few columns, one of them being Checkbox. I want to have a feature like "select/deselect Al"l and Save All.
Thank you
I have a PageBlockTable, with few columns, one of them being Checkbox. I want to have a feature like "select/deselect Al"l and Save All.
<apex:page Controller="GestionDeProduit" sidebar="false" showHeader="false" > <script type="text/javascript" language="javascript"> function checkJS(id1,id2) { var v1 =''; var v2 =''; if(document.getElementById(id1) != null){ v1 = document.getElementById(id1).value; } if(document.getElementById(id2) != null){ v2 = document.getElementById(id2).value; } checkAF(v1,v2); } </script> <apex:form id="products"> <apex:actionFunction name="checkAF" action="{!updateRow}" reRender="panelRefresh"> <apex:param name="check1" value="" /> <apex:param name="check2" value="" /> </apex:actionFunction> <apex:outputPanel id="panelRefresh" > <apex:outputPanel > <apex:pageBlock > <apex:pageBlockTable value="{!productList}" var="item"> <apex:column headerValue="Products" > <apex:outputText value="{!item.Product__r.Name}"/> </apex:column> <apex:column headerValue="Disponibilite" > <apex:inputField value="{!item.Availability__c }" id="availabilityId" onchange="checkJS('{!$Component.availabilityId}','{!$Component.primaryId}');"/> <apex:inputHidden value="{!item.Name }" id="primaryId"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:outputPanel> </apex:outputPanel> </apex:form> </apex:page> public with sharing class GestionDeProduit { transient public List<Product_Availability__c> productList{get;set;} public GestionDeProduit(){ init(); } public void init(){ try{ productList = [SELECT Name, Availability__c FROM Product_Availability__c]; }Catch(QueryException de ){ System.debug(de); } } public void updateRow(){ String temp2 = System.currentPageReference().getParameters().get('check2'); List<Product_Availability__c> pList = new List<Product_Availability__c>(); try{ pList = [SELECT Name, Availability__c FROM Product_Availability__c WHERE Name =:temp2]; }Catch(QueryException de ){ System.debug(de); } if(pList.size()>0){ if(pList[0].Availability__c == true){ pList[0].Availability__c = false; }else if(pList[0].Availability__c == false){ pList[0].Availability__c = true; } try{ update pList[0]; }Catch(DMLException de ){ System.debug(de); } } init(); } }
Thank you
http://www.sfdcpoint.com/salesforce/select-all-checkbox-using-javascript-in-visualforce-page/
You need to add below java script code.
Please let us know if this will help u
Thanks,
Amit Chaudhary
All Answers
http://www.sfdcpoint.com/salesforce/select-all-checkbox-using-javascript-in-visualforce-page/
You need to add below java script code.
Please let us know if this will help u
Thanks,
Amit Chaudhary
Can you help me, please?
I have used your code and its working fine, but I want to achieve this without using javascript because I want to convert it into lightning. So it is not possible if I use javascript. So I wish if you have any alternatives suggestions to achieve this.
Thanks,
Naveen