You need to sign in to do that
Don't have an account?
Frank Carter
visualforce inline editing not saving
Hello,
I have a problem with a VF page. I improved the vf page with the inline editing but I'm not able to save if I edit a record. In a first moment it seems it's saving but if I click the search button the page reload the record without change. I think the problem is in the save method. Can someone hepl me?
Thanks
vf page
Controller
I have a problem with a VF page. I improved the vf page with the inline editing but I'm not able to save if I edit a record. In a first moment it seems it's saving but if I click the search button the page reload the record without change. I think the problem is in the save method. Can someone hepl me?
Thanks
vf page
<apex:page controller="SearchWithWrapperC" lightningStylesheets="true" docType="html-5.0" id="pg"> <script type="text/javascript"> function selectAllCheckboxes(obj,receivedInputID){ var inputCheckBox = document.getElementsByTagName("input"); for(var i=0; i<inputCheckBox.length; i++){ if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){ inputCheckBox[i].checked = obj.checked; } } } </script> <apex:form > <apex:pageBlock title="Billing Details Search Page" > <br/> <br/> <apex:actionRegion > <center> <apex:outputLabel value="Start Date"/> <apex:input value="{!StartDate}" type="date" /><br/> <apex:outputLabel value="End Date "/> <apex:input value="{!EndDate}" type="date" /> </center> </apex:actionRegion> <br/> <div align="center" draggable="false" > <apex:commandButton value="Search" action="{!loadData}" style="text-align:left;" /> <apex:commandButton value="Moves to next month" style="text-align:left;" onclick="if(!confirm('If you click ok all the selected billing details will be paid for the current month. Are you sure? ')) return false;" action="{!processSelected}" /> </div> </apex:pageBlock> <apex:pageBlock mode="inlineEdit" id="pgblk" > <apex:pageBlockButtons > <apex:commandbutton value="save" action="{!save1}"/> </apex:pageBlockButtons> <apex:pageBlockTable value="{!listBD}" var="b"> <apex:column > <apex:facet name="header"> <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')" /> </apex:facet> <apex:inputCheckbox value="{!b.check_box}" id="inputId" /> </apex:column> <apex:column Headervalue="SF OPPORTUNITY ID"> <apex:outputfield value="{!b.cs.SF_Opportunity_Id__c}"/> </apex:column> <apex:column headervalue="BILLING TYPE"> <apex:outputfield value="{!b.cs.Billing_Type__c}"/> </apex:column> <apex:column headervalue="BILLING PERIOD" > <apex:outputfield value="{!b.cs.Billing_Period__c}"/> </apex:column> <apex:column headervalue="MONTHLY FORECAST" > <apex:outputfield value="{!b.cs.Monthly_Forecast__c}"/> </apex:column> <apex:column headervalue="END OF BILLING" > <apex:outputfield value="{!b.cs.End_of_Billing__c}"/> </apex:column> <apex:column headervalue="AMOUNT" > <apex:outputfield value="{!b.cs.Amount__c}"/> </apex:column> <apex:column headervalue="BILLING STATUS" > <apex:outputfield value="{!b.cs.Billing_Status__c}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
Controller
public class SearchWithWrapperC { public Date StartDate {get;set;} public Date EndDate {get;set;} public List<WrapperClass> listBD {get;set;} public List<Billing_Detail__c> blst=new List<Billing_Detail__c>(); public List<Billing_Detail__c> getBill(){ blst=[Select Id,SF_Opportunity_Id__c, Name,Billing_Type__c, Billing_Period__c , Monthly_Forecast__c,End_of_Billing__c, Amount__c, Billing_Status__c from Billing_Detail__c Where Billing_Status__c='Authorized for Billing'AND Monthly_Forecast__c>=:StartDate AND Monthly_Forecast__c <= :EndDate Order by Monthly_Forecast__c] ; return blst; } //save method inline editing public void save1() { update blst; } public void loadData() { listBD = new List<WrapperClass>(); for(Billing_Detail__c cr : [Select Id,SF_Opportunity_Id__c, Name,Billing_Type__c, Billing_Period__c , Monthly_Forecast__c,End_of_Billing__c, Amount__c, Billing_Status__c from Billing_Detail__c Where Billing_Status__c='Authorized for Billing'AND Monthly_Forecast__c>=:StartDate AND Monthly_Forecast__c <= :EndDate Order by Monthly_Forecast__c ]){ listBD.add(new WrapperClass (cr, false)); } } public List<WrapperClass> getBilling() { if(listBD == null) { listBD = new List<WrapperClass>(); for(Billing_Detail__c cr : [Select Id,SF_Opportunity_Id__c, Name,Billing_Type__c, Billing_Period__c , Monthly_Forecast__c,End_of_Billing__c, Amount__c, Billing_Status__c from Billing_Detail__c Where Billing_Status__c='Authorized for Billing'AND Monthly_Forecast__c>=:StartDate AND Monthly_Forecast__c <= :EndDate Order by Monthly_Forecast__c ]){ listBD.add(new WrapperClass (cr, false)); } } return listBD; } public PageReference processSelected() { Integer m = Date.Today().Month(); Integer y = Date.Today().Year(); List<Billing_Detail__c> selectedBD = new List<Billing_Detail__c>(); for(WrapperClass bd: getBilling()){ Billing_Detail__c billlingDetail ; if(bd.check_box== true){ billlingDetail = new Billing_Detail__c(Id=bd.cs.Id); billlingDetail.Monthly_Forecast__c = Date.newinstance( y , m , bd.cs.Monthly_Forecast__c.day() ); selectedBD.add(billlingDetail); } } update selectedBD; loadData(); return null; } //wrapper public class WrapperClass { public Billing_Detail__c cs {get; set;} public Boolean check_box {get; set;} public WrapperClass(Billing_Detail__c c, Boolean check_box){ this.cs = c; this.check_box = false; } } }
can someone help me?