You need to sign in to do that
Don't have an account?
geeljire
Conditionally render and save each row within apex:repeat?
Objective: Allow each record in a custom listview table to be edited and saved independently in place (in the table).
Tried so far: I set up each row to contain both an apex:inputText and apex:outputText tags in order to allow input/output toggle via the rendered attribute. So far, I can only render the entire table conditionally. I don't know how to make the toggle affect each row/record independently.
Two questions:
- How can I independently edit each record?
- How can I independently save each record?
Markup:
<apex:form><table> ... <tbody> <apex:repeat value="{!items}" var="r"> <tr> <td><apex:inputText rendered="{!inputMode}" value="{!r.sample1}"></apex:inputText><apex:outputText rendered="{!outputMode}" value="{!r.sample1}"></apex:outputText></td> <td><apex:inputText rendered="{!inputMode}" value="{!r.sample2}"></apex:inputText><apex:outputText rendered="{!outputMode}" value="{!r.sample2}"></apex:outputText></td> <td><apex:inputText rendered="{!inputMode}" value="{!r.sample3}"></apex:inputText><apex:outputText rendered="{!outputMode}" value="{!r.sample3}"></apex:outputText></td> <td><apex:inputText rendered="{!inputMode}" value="{!r.sample4}"></apex:inputText><apex:outputText rendered="{!outputMode}" value="{!r.sample4}"></apex:outputText></td> <td>{!r.CreatedBy.Name}</td> <td><apex:commandLink rendered="{!outputMode}" value="edit" action="{!enterInputMode}"/><apex:commandLink rendered="{!inputMode}" action="{!exitInputMode}" value="save"/></td> </tr> </apex:repeat> </tbody> ... </table></apex:form>
Apex class:
public with sharing class editModeControl { public Boolean inputMode{get;set;} public Boolean outputMode{get;set;} public editModeControl(ApexPages.StandardSetController controller) { inputMode = false; outputMode = true; } public PageReference enterInputMode() { inputMode = true; outputMode = false; return null; } public PageReference exitInputMode() { inputMode = false; outputMode = true; return null; } }
Please note that I have no save method implemented.
Items is a list of custom object records. Here are the details:
Full markup:
Extensions:
By the way, everything is open to change. If you think the custom listview can be presented in a way that will faciliate independent editing and saving of records, I would welcome your suggestions.