+ Start a Discussion
kito kidkito kid 

pass the exact data from 1st page to 2nd excel page

I am using search conditions in 1st page.

but when 2nd page is exported as Excel sheet, the data are not filtered out by search conditions in 1st page. All the data are showing in Excel sheet.


all the conditions are same in 1st and 2nd page. Only button , calander are moved out from 2nd page.

 

PageReference OpenNewPage = New Pagereference('/apex'+'/mysecondpage');

OpenNewPage.setRedirect(false);
return OpenNewPage;

Best Answer chosen by Admin (Salesforce Developers) 
kito kidkito kid

the walkaround for my solution that fit to me is , 

I use

 

PageReference newpage = Page.MypageName;

newpage.getParameters().put('key','value');

 

and put all necessary values into that current Page.

And then from the action class, I get those values again.

As I am using include tag and this is the final solution that works for me.

 

All Answers

amarcuteamarcute

Hi,

 

Pass the Search string to your second page like:

String sString = YOUR SEARCH STRING

PageReference OpenNewPage = New Pagereference('/apex'+'/mysecondpage+'?searchStr='+sString);

 

if you have more than 1 search Strings:

 

String sString1 = YOUR SEARCH STRING1

String sString2 = YOUR SEARCH STRING2

PageReference OpenNewPage = New Pagereference('/apex'+'/mysecondpage+'?searchStr='+sString1+'&searchStr2='+sString2);

 

 

Add a Controller to your new page & Fileter the list data using the same logic as you are using in your 1st page.

kito kidkito kid

Hi, I was using the same controller in Second Page.

 

What I don't understand is , if filtered 10 recrods displayed in First page after search result. Those results will be automatically carried towards to Second Page when I pass the Page Reference in the controller class?

 

As I believe OpenNewPage.setRedirect(false); should use the same controller with same conditions for Second Page.

 

( Or ) I still need to pass the search conditions towards Second Page and second page will call the controller again.

And the filter results (same as in First Page) will be displayed ?

 

Please help me calify.

 

Edited :

I think the problem is because of <include> tag. As I am using multiple page called from drop downdown list.

If I use the First Page directly from Browser. The code is working fine and can export the filtered record.

 

But when The First Page is  called from Main Page (using dropdown list) and export Excel, I got all the records (not filtered records).

 

Any input will be appreciated .


Thanks ahead.

sandeep@Salesforcesandeep@Salesforce

You can do it writing same code on another page but just mentioning 

VF page 1 

 

<apex:apge >

               put your code to show Data

</Apex:page>

 

Vf Page2

<apex:apge contentType="application/vnd.ms-excel" >

               put your code to show Data

</Apex:page>

 

Now you can redirect to this VF page2 from VF page1

kito kidkito kid

the walkaround for my solution that fit to me is , 

I use

 

PageReference newpage = Page.MypageName;

newpage.getParameters().put('key','value');

 

and put all necessary values into that current Page.

And then from the action class, I get those values again.

As I am using include tag and this is the final solution that works for me.

 

This was selected as the best answer