I am trying like this but its not getting exact output.
Visualforce page:
<apex:page controller="MyControlleremployee" tabStyle="employee__c">
<apex:form >
<apex:pageBlock id="blockId" title="Employee Details">
<apex:pageblocktable value="{!myemployees}" var="emp">
<apex:column >
<apex:facet name="header">{!$ObjectType.employee__c.fields.name.label}</apex:facet>
<apex:inputField value="{!emp.name}" rendered="{!tobeEdited == emp.id}"/>
<apex:outputField value="{!emp.name}" rendered="{!!(tobeEdited == emp.id)}"/>
</apex:column>
<apex:column >
<apex:facet name="header">{!$ObjectType.employee__c.fields.email__c.label}</apex:facet>
<apex:inputField value="{!emp.email__c}" rendered="{!tobeEdited == emp.id}"/>
<apex:outputField value="{!emp.email__c}" rendered="{!!(tobeEdited == emp.id)}"/>
</apex:column>
<apex:column >
<apex:facet name="header">{!$ObjectType.employee__c.fields.max_pay__c.label}</apex:facet>
<apex:inputField value="{!emp.max_pay__c}" rendered="{!tobeEdited == emp.id}"/>
<apex:outputField value="{!emp.max_pay__c}" rendered="{!!(tobeEdited == emp.id)}"/>
</apex:column>
<apex:column >
<apex:facet name="header">{!$ObjectType.employee__c.fields.min_pay__c.label}</apex:facet>
<apex:inputField value="{!emp.min_pay__c}" rendered="{!tobeEdited == emp.id}"/>
<apex:outputField value="{!emp.min_pay__c}" rendered="{!!(tobeEdited == emp.id)}"/>
</apex:column>
<apex:column >
<apex:commandbutton value="Edit" rerender="blockId" rendered="{!!(tobeEdited == emp.id)}" >
<apex:param assignTo="{!tobeEdited}" value="{!emp.id}" name="ittobeedited"/>
</apex:commandbutton>
<apex:commandbutton value="save" rerender="blockId" rendered="{!!(tobeEdited == emp.id)}" />
<apex:commandButton value="save" action="{!saveRecord}" reRender="blockId" rendered="{!tobeEdited == emp.id}"/>
<apex:commandButton action="{!Deleted}" value="Deleted" />
<apex:commandButton action="{!Download}" value="Download"/>
</apex:column>
</apex:pageblocktable>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex class:
public class MyControlleremployee {
public PageReference Download() {
PageReference nextpage = new PageReference('/apex/ExcelReportPage?recordID');
return nextpage;
}
public List<employee__c> myemployees;
public id tobeEdited{get; set;}
public MyControlleremployee(){
}
public List<employee__c> getMyemployees(){
myemployees = [select Id,name,email__c,max_pay__c,min_pay__c from employee__c WHERE (owner.id =: userinfo.getuserid()) ];
return myemployees;
}
public void saveRecord(){
employee__c tobeupdated;
for(employee__c temp:myemployees){
if(temp.id==tobeEdited){
tobeupdated = temp;
break;
}
}
update tobeupdated;
tobeEdited = null;
}
public void Deleted(){
employee__c tobedeleted;
for(employee__c tmp:myemployees){
tobedeleted = tmp;
delete tobedeleted;
tobedeleted = null;
}
}
}
Pagereference page:
<apex:page contentType="application/x-excel#reRenderAsTestFile.xls" Controller="MyControlleremployee">
<apex:pageBlock >
<apex:pageblockTable value="{!myemployees}" var="v" border="1"
columnsWidth="100px,200px,150px" cellspacing="0" cellpadding="8">
<apex:column headerValue="name">{!v.name}</apex:column>
<apex:column headerValue="email__c">{!v.email__c}</apex:column>
<apex:column headerValue="max_pay__c">{!v.max_pay__c}</apex:column>
<apex:column headerValue="min_pay__c">{!v.min_pay__c}</apex:column>
</apex:pageblockTable>
</apex:pageBlock>
</apex:page>
can anybody help me.
userinfo.getuserid()
, then copy the SQL statement and run it in the Developer Console. Does it look correct to you? Nowhere in your question do you mention that you want only a single record but you are getting many. To be kind to others who might be trying to answer your question, please edit it so that it is more clear.where ownerId = :UserInfo.getuserId()
2) what isrecordId
in the URL of the download() action method? syntax doesnt look correct 3) you could make everyone's life easier here if you stripped out the unnecessary bits such as the save and delete methods