function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
coolKarnicoolKarni 

dynamically catching the ids in datatable

Hi,

I have a table in a pageblock , here i have links on each row.

My requiremnt is to get the ids of link whenever clicked on a particular link dynamically.

 

can i catch the id of link dynamically in javascriprt such that i can pass those values to another page. 

Is that possible???

 

Thanks

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

You can pass the id to the closepopup method as a parameter.

 

E.g.

 

 <apex:smileysurprised:utputLink id="outputLink" onclick="return closePopup('{!acc.id}');" >

All Answers

bob_buzzardbob_buzzard

Assuming you are using commandlinks, you can use a nested apex:param to pass this back to the controller.

 

 

E.g.

 

<apex:commandLink action="{!editObj}" value="Edit"> <apex:param name="editId" assignTo="{!selectedObjectId}" value="{!obj.id}"/> </apex:commandLink>

 

where obj is the var that you are using to iterate the list backing the table.

 

 

coolKarnicoolKarni

Hi ,

 

Here is my code:

 

<apex:page sidebar="false" showHeader="false" controller="ChildPopup">
<script type="text/javascript">
function closePopup()
{
var label = document.getElementById('j_id0:j_id2:j_id3:j_id4:0:label');
window.parent.opener.document.getElementById('j_id0:j_id1:pageBlock:section:contractNo').value= label.innerHTML ;
var winMain = window.opener;
if(null == winMain)
{
    winMain = window.parent.opener;
}
winMain.closePopup1();
}
</script>
<apex:form >
<apex:pageBlock title="Contract Number">
<apex:pageBlockTable value="{!accountDetails}" var="acc" >
<apex:column >
<apex:outputLink id="outputLink" onclick="return closePopup();" >
<apex:outputLabel id="label" value="{!acc.Contract_Number__c} "></apex:outputLabel>
</apex:outputLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>

 </apex:form>
</apex:page>

 

 

Now here the PageBlock Table is binded dynamically.In this we have an output label inside the link .

This links are binded dynamically.

My issue overhere is i am able to get the id of label from a list of links . when clicked on  a particular link.

I am able to catch the id of single link from a list of links.

currently i am able to catch the id of a particular link as document.getElementById('j_id0:j_id2:j_id3:j_id4:0:label');

 

So how can i get the id  of a link which is clicked from  a list of links

 

 

 

bob_buzzardbob_buzzard

You can pass the id to the closepopup method as a parameter.

 

E.g.

 

 <apex:smileysurprised:utputLink id="outputLink" onclick="return closePopup('{!acc.id}');" >

This was selected as the best answer
coolKarnicoolKarni

That was so easy..

Thanks for soln bob.