1

I have the following code.

<apex:outputPanel id="deliveryRights" rendered="true">
<table id="table">
    <thead>
        <tr>
            <th>Category:</th>
            <th>Product:</th>
            <th>Details:</th>
            <th>Delivered:</th>
        </tr>
    </thead>
    <tbody>
        <apex:repeat value="{!RightsTrackerListDelivery}" var="O">
            <tr>
                <td>
                    <apex:inputField value="{!O.Category__c}"/>
                </td>
                <td>
                    <input type="text" value="{!O.Product__c}"/>
                </td>
                <td>
                    <input type="text" value="{!O.Details__c}"/>
                </td>
                <td>
                    <apex:inputField value="{!O.Delivered__c}"/>
                </td>
            </tr>
        </apex:repeat>
    </tbody>
</table>
<div>
    <apex:commandLink value="Add New Delivery Record" onClick="addTableRow();" id="addRowDelivery"/>
</div>


I have a list callled RightsTrackerListDelivery. When I edit the contents of the table I would like to be able to track the changes and update the rows dynamically.

I know this would be easier if I used an Apex component but I am forced to use a Apex repeat component.

I am using input fields to display the table data. I have the logic to add a new row but as for actually taking the new / editited values and passing them to the controller to update the list I'm a bit stuck.

Should I just loop though every cell, convert it all to a JSON object and pass it to the server?

Any ideas?

8
  • 1
    I m bit confuse with your requirement i.e. I used an Apex component but I am forced to use a Apex repeat component. ? – Ratan Paul Jun 7 '16 at 9:44
  • 1
    Sam if you just use apex:inputField then your enter data automatically binded with your list. You can get those value in controller. no need to use json etc.. – Ratan Paul Jun 7 '16 at 9:47
  • 1
    If you post your controller it would be helpful. Since you are using apex:repeat your collection is already accessible from apex – highfive Jun 7 '16 at 9:49
  • 1
    Yes Sam you need to just perform update/upsert operation on that list.. nothing else everything will work fine – Ratan Paul Jun 7 '16 at 10:04
  • 1
    @SamCousins yeah salesforce made everything very easy. give me few mins I will add answer to this question. – Ratan Paul Jun 7 '16 at 10:11
3

Since You are not aware of this. But if we use the apex:inputField in VF page then we can bind the data into list from Vf page

like

<apex:repeat value="{!mylist}" var="sobject">
     <apex:inputField value="{!sobject.Field1}" /> 
     <apex:inputField value="{!sobject.Field2}" /> 
  </apex:repeat>

This is will bind the value into your list. Whatever changes you made in this list, it will be binded into list and you can get those values in controller

so you need to perform update/ upsert DML on this list and everything should work fine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy