You need to sign in to do that
Don't have an account?
Supriyo Ghosh 5
Simple apex code and vf page
Hi,
I want to create a report through vf page.My object name is EmpMaster.I want to display name,address and Emp code.Can anyone help me with the apex code and vf page.
Name Address EmpCode
Suman Kolkata 20012
Saha West Bengal 50026
I want to display like this.Please help.
I want to create a report through vf page.My object name is EmpMaster.I want to display name,address and Emp code.Can anyone help me with the apex code and vf page.
Name Address EmpCode
Suman Kolkata 20012
Saha West Bengal 50026
I want to display like this.Please help.
Standrad controller
public class EmpMasterReport
{
public List<Employee_Master__c> EmpList {get;set;}
public EmpMasterReport(ApexPages.StandardController stdController) {
{
EmpList = new List<Employee_Master__c>();
EmpList = [ SELECT Name,Address__c FROM Employee_Master__c ];
}
public EmpMasterReport()
{
EmpList = new List<Employee_Master__c>();
EmpList = [ SELECT Name,Address__c FROM Employee_Master__c ];
}
}
VF page
<apex:page id="p1" standardController="Employee_Master__c" extensions="EmpMasterReport" sidebar="false">
<apex:form>
<apex:pageBlock title="Employee Master Details" id="Emp_Master">
<apex:pageBlockTable value="{! EmpList }" var="em">
<apex:column value="{! em.Name}"/>
<apex:column value="{!em.Address__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Let us know if this will help you.
Thanks
Amit Chaudhary
All Answers
1) https://developer.salesforce.com/trailhead/en/visualforce_fundamentals/visualforce_standard_controllers
2) https://developer.salesforce.com/trailhead/en/module/visualforce_fundamentals
Sample code for you for contact object. You can add your custom object name
Let us know if this will help you
I have written the standrad controller and vf page.but unable to fetch the data.Please help.
Standrad controller
public class EmpMasterReport
{
public List<Employee_Master__c> EmpList{get;set;}
public EmpMasterReport(){
EmpList = [ SELECT Name,Address__c FROM Employee_Master__c ];
}
}
vf page
<apex:page id="p1" standardController="Employee_Master__c" extensions="EmpMasterReport" sidebar="false">
<apex:form>
<apex:pageBlock title="Employee Master Details" id="Emp_Master">
<apex:pageBlockTable value="{! Employee_Master__c }" var="em">
<apex:column value="{! em.Name}"/>
<apex:column value="{!em.Address__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Standrad controller
public class EmpMasterReport
{
public List<Employee_Master__c> EmpList {get;set;}
public EmpMasterReport(ApexPages.StandardController stdController) {
{
EmpList = new List<Employee_Master__c>();
EmpList = [ SELECT Name,Address__c FROM Employee_Master__c ];
}
public EmpMasterReport()
{
EmpList = new List<Employee_Master__c>();
EmpList = [ SELECT Name,Address__c FROM Employee_Master__c ];
}
}
VF page
<apex:page id="p1" standardController="Employee_Master__c" extensions="EmpMasterReport" sidebar="false">
<apex:form>
<apex:pageBlock title="Employee Master Details" id="Emp_Master">
<apex:pageBlockTable value="{! EmpList }" var="em">
<apex:column value="{! em.Name}"/>
<apex:column value="{!em.Address__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Let us know if this will help you.
Thanks
Amit Chaudhary
You just need to change this line:
<apex:pageBlockTable value="{! Employee_Master__c }" var="em">
Replace it with this: Hope this helps!
Kind Regards,
Sourav.
I want to download this report as PDF.Any idea how to do that.Please help.
Please start a new thread (new question) so that other can help you