You need to sign in to do that
Don't have an account?

Inlineedit and datatable using a custom controller
I've got a page that was originally designed for listing/selecting records from a datatable...
I'm using a custom controller to query the "Payment" object I want and then I stick those in a wrapper so I can select the ones I want to process.
Client came back and said they'd like inlineediting, so I stuck it in, but can't figure out how to update the data once it's been changed.
I think the problem is that when I edit a piece of data, it's never "set" back in the list, but I'm stumped on doing that...might just be a long day. Anyone have a thought?
I'm sure I just need to stick a {set;} somewhere, but I just don't know where...
Thanks.
here's the vf page code:
<apex:pageblocksection title="Request Refunds" columns="1" collapsible="FALSE" > <apex:dataTable value="{!payments}" var="p" width="100%"> <apex:column > <apex:inputCheckbox value="{!p.selected}" id="checkedone" disabled="{!p.pay.Refund_Requested__c}"> <apex:actionSupport event="onclick" action="{!GetSelected}" rerender="totalsection"/> </apex:inputCheckbox> </apex:column> <apex:column headervalue="Reference Nbr" value="{!p.pay.Name}" /> <apex:column headervalue="Payment Date" value="{!p.pay.Payment_Date__c}" /> <apex:column headervalue="Payment Type" value="{!p.pay.Payment_Type__c}" /> <apex:column headervalue="Status" value="{!p.pay.Payment_Status__c}" /> <apex:column headervalue="Amount" value="{!p.pay.Payment_Amount__c}" /> <apex:column headervalue="Refund Requested" value="{!p.pay.Refund_Requested__c}" /> <apex:column headervalue="Type" value="{!p.pay.RecordType.Name} - {!p.pay.Refund_for_Payment__r.Name}"/> <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" /> </apex:dataTable> </apex:pageblocksection>
I tried to give the simplified version...okay, the controller:
public with sharing class ctrl_Refund { List<paymentwrapper> PaymentList = new List<paymentwrapper>(); List<CCPayment__c> SelectedPayments = new List<CCPayment__c>(); public ctrl_Refund() { //get thelist of payments Payments list<CCPayment__c> plist = [select p.id,p.name,p.payment_status__c, p.payment_date__c, p.payment_amount__c, p.payment_type__c, p.refund_requested__c, p.opportunity__c,p.Refund_for_Payment__r.Name, p.RecordType.Name from CCPayment__c p where p.opportunity__c = :id]; for(CCPayment__c p : plist){ PaymentList.add(new paymentwrapper(p)); } system.debug('### Out of for loop - PaymentList: ' + PaymentList); if(PaymentList.size()>0){ HasCollectedPayments = True; } else {HasCollectedPayments = False;} } public PageReference getSelected() { SelectedPayments.clear(); for(paymentwrapper paywrapper : PaymentList){ if(paywrapper.selected == true && paywrapper.pay.Refund_Requested__c == false) { selectedPayments.add(paywrapper.pay); } } return null; } public class paymentwrapper { public CCPayment__c pay {get; set;} public Boolean selected {get; set;} public paymentwrapper(CCPayment__c p) { pay = p; selected = false; } } }
Additional info...
When I change:
to:
I am abel to update/save, but...it is in edit mode. When I changed to apex:outputfield instead...all is well in the world.
So...I thnk I'm good...just need to do:
All Answers
Your data should be updated in the list without you having to manually set it in, as you are using sobject fields to back the values and they have setters available by default.
Thus your save action method should simply be able to iterate the wrapper class list and update the CCPayment__c objects into the database.
I wrote a blog post on this which may help to explain things:
http://bobbuzzard.blogspot.com/2011/03/persisting-list-edits-in-visualforce.html
If I'm using a custom controller (not a standard controller + extention)...does this change anything?
In your post, you update the standard controller (Account/std), and separately update contacts...I'm essentially skipping the account update, which should be fine...but after my inline editing, it does not seem to be setting the wrapper classes inner sobject. Do I need to specify the "set" somewhere?
It would really have been nice to have a solid java background years ago...but hacking my way through a career has worked so far :)
Additional info...
When I change:
to:
I am abel to update/save, but...it is in edit mode. When I changed to apex:outputfield instead...all is well in the world.
So...I thnk I'm good...just need to do: