I have a skill_Review__c object which has two lookup fields in them - Skills__c and Level__c.
Below is my VF and controller. I am trying to get the user input on level field by clicking the edit button VF page and when I save it the level entered by user should be updated to the Level__c on skill_review__c object.
I have created a skillreview list where I store the level__c and skill__c for a particular skill_review__c object. How can I display the skillreviewlist in my VF page and how can I update the level__c record from the value entered from level drop down list.
VFpage:
<apex:page standardController="Interview__c" extensions="SkillReviewExtension" showHeader="false">
<apex:form >
<apex:pageBlock title="Technical Skill Evaluation" id="skills_list">
<apex:pageBlockButtons location="top">
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Edit" action="{!Edit}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{! SkillReviewList }" var="rt" >
<apex:column value="{!rt.SkillReview.Skill__c}"/>
<apex:column value="{! rt.SkillReview.Level__c}"/>
<apex:column headerValue="Level">
<apex:selectList value="{!rt.level}" multiselect="false" size="1" rendered="{!isEditMode}">
<apex:selectOption itemValue="1" itemLabel="1"/>
<apex:selectOption itemValue="2" itemLabel="2"/>
<apex:selectOption itemValue="3" itemLabel="3"/>
<apex:selectOption itemValue="4" itemLabel="4"/>
<apex:selectOption itemValue="5" itemLabel="5"/>
</apex:selectList>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller extension:
public class SkillReviewExtension{
private final Interview__c review;
public boolean IsEditMode {get;private set;}
public String Level{get;set;}
public List<SkillReview> SkillReviewList{get;set;}
public SkillReviewExtension(ApexPages.StandardController stdController) {
this.review= (Interview__c)stdController.getRecord();
initSkillReviews();
}
private void initSkillReviews() {
skillReviewList=new List<skillReview>();
for(Skill_Review__c sr: [SELECT Id,Name,Skill__c,Level__c FROM Skill_Review__c where Interview__c =:review.id ]){
skillReviewList.add(new SkillReview(sr));
}
}
public PageReference save(){
isEditMode=false;
skillReviewList[0].SkillReview.Level__c=Level;
update SkillReviewList[0].SkillReview;
return null;
}
public PageReference edit(){
isEditMode=true;
return null;
}
}
SkillReview class:
public class SkillReview{
public Skill_Review__c SkillReview{get;set;}
public String Level{get;set;}
public SkillReview(Skill_Review__c skillReview){
this.skillReview = skillReview;
this.Level = skillReview.Level__c;
}
//skillReview.Level__r.Name;
}
Skill_review__c object has skill__c and level__c as a lookup field in it.
<apex:inputText value="fieldAPIName" />
this way you can bind the value – Ratan Paul Mar 17 '16 at 4:01lebel__c
is lookup field. If yes then what should happens you select1
in picklist and is there anyLevel__c
record with name or something unique1
? ... based on selected picklist value we can query theLevel__c
record Id and then we can assign that Id toSkillReview.Level__c
.. after that we can perform Update DML onSkillReview
record. – Ratan Paul Mar 17 '16 at 4:49