You need to sign in to do that
Don't have an account?
Koustubh Kulkarni
How to display records on a pageblocktable based on the value of a picklist field?
i i am new to salesforce. I want to display some records on a pageblocktable, which must be based on the picklist field. e.g. If i select Quarter4 from quarter picklist field pageblocktable must show records for the particular quarter. Anyone know how to do that? I am attaching my VF page and controller code here. VF page-
<apex:page standardController="contact" extensions="cntrl_bulk_test"> <!-- controller="cntrl_bulk_test" -->
<apex:form id="frm">
<apex:pageBlock id="pgBlkSkilllevel">
<apex:pageBlockTable value="{!lsttopiclevel1 }" var="a">
<apex:column headerValue="Skill Group">
<apex:outputField value="{!a.Skill_Group__c}"/>
<!-- <apex:inputfield value="{!a.Skill_Group__c}"/> -->
</apex:column>
<apex:column headerValue="Topic Name">
<apex:outputField value="{!a.Topic__r.Name}"/>
</apex:column>
<apex:column headerValue="Skill Target">
<apex:outputField value="{!a.skill_level_expected__c}"/>
</apex:column>
<apex:column headerValue="Skill Level">
<apex:inputfield value="{!a.Skill_Level__c}"/>
</apex:column>
<apex:column headerValue="Year">
<apex:inputfield value="{!a.Year__c}"/>
</apex:column>
<apex:column headerValue="Quarter">
<apex:inputfield value="{!a.Quarter__c}"/>
</apex:column>
</apex:pageBlockTable>
<br/>
<apex:commandButton value="Save" action="{!saveSkillLevelRating}" /> <!--onclick="window.top.location='/{!Contact.id}'; return false"-->
</apex:pageBlock>
</apex:form>
</apex:page>
controller-
public with sharing class cntrl_bulk_test
{
Public static Id EmployeeId {get;set;}
Public List<Contact_Topic_Scale__c> lsttopiclevel{get;set;}
list<Contact_Topic_Scale__c> LstSkilllevels = new list<Contact_Topic_Scale__c>();
public List<Contact_Topic_Scale__c> lsttopiclevel1 {get;set;}
public ApexPages.StandardController controller {get; set;}
public cntrl_bulk_test(ApexPages.StandardController controller)
{
this.controller = controller;
EmployeeId =system.currentpagereference().getparameters().get('id');
Contact coninfo = [select name from contact where id =: controller.getId()];
lsttopiclevel1 = new List<Contact_Topic_Scale__c>([SELECT Id, Core_Skill_Set__c,Contact_Skill_Set__c,Delta_Actual_vs_Expected__c,Employee__c,Quarter__c,Skill_Group__c,Skill_Level__c,skill_level_expected__c,Year__c,Topic__r.Name FROM Contact_Topic_Scale__c where Employee__c =: coninfo.name ORDER BY Skill_Group__c ASC ]);
}
Public PageReference saveSkillLevelRating()
{
//controller.save(); // call save method from standart controller
//System.debug('*******saveSkillLevelRating0*******');
//PageReference pageRef = system.currentpagereference();
PageReference pageRef = ApexPages.currentPage();
System.debug('********************************************************************************lsttopiclevel=' + lsttopiclevel1 );
update lsttopiclevel1 ;
System.debug('********************************************************************************lsttopiclevel=' + lsttopiclevel1 );
return null;
//return pageRef ;
}
}
<apex:page standardController="contact" extensions="cntrl_bulk_test"> <!-- controller="cntrl_bulk_test" -->
<apex:form id="frm">
<apex:pageBlock id="pgBlkSkilllevel">
<apex:pageBlockTable value="{!lsttopiclevel1 }" var="a">
<apex:column headerValue="Skill Group">
<apex:outputField value="{!a.Skill_Group__c}"/>
<!-- <apex:inputfield value="{!a.Skill_Group__c}"/> -->
</apex:column>
<apex:column headerValue="Topic Name">
<apex:outputField value="{!a.Topic__r.Name}"/>
</apex:column>
<apex:column headerValue="Skill Target">
<apex:outputField value="{!a.skill_level_expected__c}"/>
</apex:column>
<apex:column headerValue="Skill Level">
<apex:inputfield value="{!a.Skill_Level__c}"/>
</apex:column>
<apex:column headerValue="Year">
<apex:inputfield value="{!a.Year__c}"/>
</apex:column>
<apex:column headerValue="Quarter">
<apex:inputfield value="{!a.Quarter__c}"/>
</apex:column>
</apex:pageBlockTable>
<br/>
<apex:commandButton value="Save" action="{!saveSkillLevelRating}" /> <!--onclick="window.top.location='/{!Contact.id}'; return false"-->
</apex:pageBlock>
</apex:form>
</apex:page>
controller-
public with sharing class cntrl_bulk_test
{
Public static Id EmployeeId {get;set;}
Public List<Contact_Topic_Scale__c> lsttopiclevel{get;set;}
list<Contact_Topic_Scale__c> LstSkilllevels = new list<Contact_Topic_Scale__c>();
public List<Contact_Topic_Scale__c> lsttopiclevel1 {get;set;}
public ApexPages.StandardController controller {get; set;}
public cntrl_bulk_test(ApexPages.StandardController controller)
{
this.controller = controller;
EmployeeId =system.currentpagereference().getparameters().get('id');
Contact coninfo = [select name from contact where id =: controller.getId()];
lsttopiclevel1 = new List<Contact_Topic_Scale__c>([SELECT Id, Core_Skill_Set__c,Contact_Skill_Set__c,Delta_Actual_vs_Expected__c,Employee__c,Quarter__c,Skill_Group__c,Skill_Level__c,skill_level_expected__c,Year__c,Topic__r.Name FROM Contact_Topic_Scale__c where Employee__c =: coninfo.name ORDER BY Skill_Group__c ASC ]);
}
Public PageReference saveSkillLevelRating()
{
//controller.save(); // call save method from standart controller
//System.debug('*******saveSkillLevelRating0*******');
//PageReference pageRef = system.currentpagereference();
PageReference pageRef = ApexPages.currentPage();
System.debug('********************************************************************************lsttopiclevel=' + lsttopiclevel1 );
update lsttopiclevel1 ;
System.debug('********************************************************************************lsttopiclevel=' + lsttopiclevel1 );
return null;
//return pageRef ;
}
}
then in the class add
public string test {get;set;}
//some code
lsttopiclevel1 = [your query .... where <YOUR FIELD NAME> = : test]