You need to sign in to do that
Don't have an account?
swetha Rao 19
Display accounthistory or contacthistory records in a pageblock table
I want to display accounthistory or contacthistory records in a pageblock table when i select accounthistory or contactHistory from a picklist.
Example:: picklist values accountHistory , if i select this the account history records should display?How?..Can any one help me please..
Example:: picklist values accountHistory , if i select this the account history records should display?How?..Can any one help me please..
Refer below page and controller.
Page:
Controller:
Thanks,
Dhanya
All Answers
Refer below page and controller.
Page:
Controller:
Thanks,
Dhanya
Can you please tell me why I am getting this error..
In your organization somewhere you have created a class named "ContactHistory". Thats why the compiler is not able to understand that it is standard Object ContactHistory or the class created by you. Please rename your class, it will work.
If the above doesn't work then try this: List<Schema.ContactHistory> lstContactHistories {get;set;}
I need checkbox in that above PageblockTable? Can anyone help me please?
Which field's history you want to track from this vf page?
Only one field's history you can track itseems.
Thanks,
Dhanya
what about checkbox in pageblock table to delete records?
Please refer this link you will get some idea to implement in your code.
http://sfdcsrini.blogspot.com/2014/12/adding-and-deleting-rows-dynamically-in.html
<apex:page controller="DeleteRecords_wrapperClass">
<apex:form >
<apex:pageBlock >
<apex:selectList value="{!SObjects}" size="1">
<apex:selectOptions value="{!SelectObjects}"/>
<apex:actionSupport event="OnChange" action="{!DisplayRecords}" reRender="Pgrf" />
</apex:selectList>
</apex:pageBlock>
<apex:pageBlock Id="Pgrf" rendered="{!Hide}">
<apex:pageBlockButtons >
<apex:commandButton value="Delete" action="{!Remove}" />
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!courseRecords}" var="c">
<apex:column >
<apex:inputCheckbox value="{!c.isselected}" id="InputckId"/>
</apex:column>
<apex:column >
{!c.cse.Name}
</apex:column>
<apex:column >
{!c.cse.course_fee__c}
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
public with sharing class DeleteRecords_wrapperClass {
public String SObjects { get; set; }
public Boolean Hide { get; set; }
Public List<wrap> Wraplist {get; set;}
public DeleteRecords_wrapperClass(){
hide= false;
}
public List<SelectOption> getSelectObjects() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('None','None'));
options.add(new SelectOption('Course','Course'));
options.add(new SelectOption('Student','Student'));
return options;
}
public Void DisplayRecords() {
Hide= True;
system.debug('##SObjects '+SObjects);
if(SObjects=='Course'){
for(Course__c c3:[select id, Name,course_fee__c from Course__c]){
system.debug('##c3 '+c3);
Wraplist.add(new wrap(c3));
system.debug('##Wraplist '+Wraplist);
}
}
}
//wrap w;
Public list<Course__c> selected {get; set;}
public List<wrap> getcourseRecords(){
Wraplist = new List<wrap>();
for(Course__c c1:[select id, Name,course_fee__c from Course__c]){
// w = new Wrap(c1);
// W.isselected = false;
// w.cse=c1;
Wraplist.add(new wrap(c1));
}
// Wraplist.add(w);
Return Wraplist;
}
Public void Remove(){
selected = new list<Course__c>();
for(wrap c2:Wraplist){
if(c2.isselected==true){
selected.add(c2.cse);
}
}
Delete selected;
}
Public class wrap{
public Course__c cse {get; set;}
public boolean isselected {get; set;}
public wrap(course__c cc){
cse=cc;
isselected=False;
}
}
}