+ Start a Discussion
diydiy 

How i pass corresponding row id in to popup window?

How i pass corresponding row id in to popup window?

 

public ID rowId {get;set;}
public Item_Assets__c objForPage2{get;set;}
public Pagereference goToPage2(){
 
for(incident_Item_Assets__c obj : IncConfigsItemAsset){
            if(obj.id==rowId){
                objForPage2= obj;
      
            }
        }
     return page.vfactivitypopup;

 

<script>
        var myWindow;
        function pop() {
            myWindow = window.open('/apex/vfactivitypopup','','width=550,height=450');
        }
       
    </script>

<apex:column >
<apex:commandLink action="{!goToPage2}"  value="popup"  onclick="pop();"   >
  <apex:param name="rowId" assignTo="{!rowId}" value="{!com1.id}"  />
</apex:commandLink>
</apex:column> 
Best Answer chosen by Admin (Salesforce Developers) 
Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

Hi Diya,

 

On seeing your code, I can understand you need to pass the object's id '{!com1.id}' in the popup.

 

Try the following,

 

<script>
var myWindow;
function pop() {
myWindow = window.open('/apex/vfactivitypopup?id={!com1.id}','','width=550,height=450');  //the value of the param should be passed here 
}
</script>

 

(Or)

 

Directly you can give the popup in the commandlink onclick event.

 

<apex:column >
<apex:commandLink action="{!goToPage2}" value="popup" onclick="window.open('/apex/vfactivitypopup?id={!com1.id}','','width=550,height=450');" >
<apex:param name="rowId" assignTo="{!rowId}" value="{!com1.id}" />
</apex:commandLink>
</apex:column>

 

Hope so this helps you...!

Please mark this answer a Solution and please give kudos by clicking on the star icon, if you found this answer as helpful.

All Answers

Gaurish Gopal GoelGaurish Gopal Goel

In JavaScript we can access the controller variables. Rowid can be accessed like:

 

<script>
        var myWindow;
        function pop() {
            myWindow = window.open('/apex/vfactivitypopup',"{!rowid}",'width=550,height=450');
        }
       
    </script>
Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

Hi Diya,

 

On seeing your code, I can understand you need to pass the object's id '{!com1.id}' in the popup.

 

Try the following,

 

<script>
var myWindow;
function pop() {
myWindow = window.open('/apex/vfactivitypopup?id={!com1.id}','','width=550,height=450');  //the value of the param should be passed here 
}
</script>

 

(Or)

 

Directly you can give the popup in the commandlink onclick event.

 

<apex:column >
<apex:commandLink action="{!goToPage2}" value="popup" onclick="window.open('/apex/vfactivitypopup?id={!com1.id}','','width=550,height=450');" >
<apex:param name="rowId" assignTo="{!rowId}" value="{!com1.id}" />
</apex:commandLink>
</apex:column>

 

Hope so this helps you...!

Please mark this answer a Solution and please give kudos by clicking on the star icon, if you found this answer as helpful.

This was selected as the best answer
diydiy

both the code are not working

Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

Try this,

 

window.open('/apex/vfactivitypopup?id='+{!com1.id},'','width=550,height=450');

 

 

Hope so this helps you...!

Please mark this answer a Solution and please give kudos by clicking on the star icon, if you found this answer as helpful.

diydiy

mycode:

 

public ID rowId {get;set;}
public incident_Item_Assets__c objForPage2{get;set;}
public Pagereference goToPage2(){

for(incident_Item_Assets__c obj : IncConfigsItemAsset){
if(obj.id==rowId){
objForPage2= obj;
System.debug('test123'+objForPage2);
}
}
return page.vfactivitypopup;
}


public Activity_Asset__c getactasset() {
if(actasset == null) actasset= new Activity_Asset__c();
return actasset;
}


public void activitysave(){
actasset.AssetID__c = objForPage2.id;
Insert actasset;
}
}

 

page- 1

<apex:commandLink action="{!goToPage2}" value="popup" onclick="window.open('/apex/vfactivitypopup?id={!com1.id}','','width=550,height=450');" > >
<apex:param name="rowId" assignTo="{!rowId}" value="{!com1.id}" />
</apex:commandLink>

page 2

<apex:panelGrid columns="2">
<apex:outputText value="Incident Item Asset"/>
<apex:outputText style="font-weight:bold" value="{!objForPage2.id}"/>
</apex:panelGrid>

Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

Hi,

 

In the page1 commandlink do the following changes and try again,

 

page- 1

<apex:commandLink action="{!goToPage2}" value="popup" onclick="window.open('/apex/vfactivitypopup?id='+{!com1.id},'','width=550,height=450');" > >
<apex:param name="rowId" assignTo="{!rowId}" value="{!com1.id}" />
</apex:commandLink>

 

Gaurish Gopal GoelGaurish Gopal Goel

Hi Diya,

 

I have used controller variables in javascript by putting the variable in double quotes like : "{!variable}"

 

We can only access these variables but we can't change the values.

diydiy

sorry its not working

diydiy

Thanks gaurish and kamatchidevi .. its working fine