You need to sign in to do that
Don't have an account?
Jonathan Jacobs
Customize the save button when editing a table of data
I have a visualforce page I am working on in which I am trying to edit a list of related records in a table format and save all the records with a single save button. I created a purchase order object and a related purchase order products, which is the individual line item records that will go on the purchase order. I used the Editing a Table of Data in a Page as my basis for creating the editiable table in visualforce. The table draws in the related items for the purchase order. I'm having trouble figuring out how to customize the save button to save the changes in the table. I believe the save button is using the standard controller and trying to save the purchase order record. I would like to customize the save button so that it can save the purchase order items in the editable table. I'm learning how to code and i'm not sure how to set this up. I'm thinking a controller extension to customize the save button, but I'm not sure how this would be coded. Any help would be appreciated.
Here is an example of the page currenlty
And here is my current Visualforce Code
Here is an example of the page currenlty
And here is my current Visualforce Code
<apex:page standardController="Purchase_Order__c" > <apex:slds /> <apex:detail inlineEdit="true"/> <!--<flow:interview name="AddProduct" />--> <apex:form> <apex:pageBlock title="Purchase Order Items"> <apex:pageBlockTable value="{!Purchase_Order__c.Purchase_Order_Products__r}" var="POLI"> <apex:column value="{!POLI.POLI_Part_Number__c}"/> <apex:column value="{!POLI.Catalog_Number__c}"/> <apex:column value="{!POLI.UOM__c}"/> <apex:column value="{!POLI.ordered__c}"/> <apex:column headerValue="Backordered"> <apex:inputField value="{! POLI.Backordered__c }"/> </apex:column> <apex:column headerValue="Received"> <apex:inputField value="{! POLI.Received__c }"/> </apex:column> <apex:column headerValue="RMA"> <apex:inputField value="{! POLI.RMA__c }"/> </apex:column> </apex:pageBlockTable> <apex:pageMessages /> <apex:pageBlockButtons> <apex:commandButton value="Save" action="{!save}"/> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
Secondly, I don't think I am setting up the save method in the extension controller correctly. Here is my class code
I have reviewed the link and I'm still having trouble understanding how to set up the extension. Do you see where my mistake is? I assume I have to get the ID of the Purchase Order record and then I need to set up a query that returns the line items that are related to the purchase order. But it seems I'm still missing something since I'm getting the unknown constructor error.
I updated the button on the visualforce page to "lineItemsSave()" so that it matches the one on the class, but I'm still not getting it to save.
Thanks for the help!
Here's a sample code that lets you write an extension and use that on the VF page. Let me know if this helps.
Notice that I have not made any change on the VF's save method, but added the extension only. And within the extension, I am in this example doing nothing and returning back to the same page where I was without making any actual save on the records.
VF:
Extension:
Thanks,
Jayant