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
The KnightThe Knight 

Not able to pass the list of objects to javascript from the controller.

Hi,

    I am not able  to send the List of Objects to javascript to generate the bar or pie chart.

    Here is the scenario. There is an apex controller class 'Agents' in that there is a method gettopNAgents() which returns List of Objects(Agents) .

 I am calling this method  in <apex:Pageblocktable  id="table" value="{!topnAgents}" var="com">......</a..:pbt> component  to display all the agents with their respective commission. The data is getting displayed in the table properly but I am not able to send the List to the javascript. I tried calling onRowClick event on pageBlocktable component and oncomplete event on commandbutton component both were not working. 

In javascript I have used var m = document.getElementById(" {!$component.table}"),  var e = "{!topnAgents}"  both were not working. Can any one help me in this.

 

 

dkraundkraun
var m = document.getElementById(" {!$Component.table}"), is the right way to go, but the problem is most likely the way you are using $Component.  It only recognizes direct children/siblings in the dom so you will need to give a complete path, for example:

<script>
   var m = document.getElementById(" {!$Component.block.table}");
</script>
<apex:pageBlock id='block'>
  <apex:pageBlockTable id='table'>

Notice how the full path from the javascript to the table is given using id's and dot notation.  If this does not solve the problem you may want to try posting more of your code.

-David
dchasmandchasman
The documentation describes things incorrectly w.r.t. the component ids and DOM ids:

If the component you want to access is a direct descendant or a sibling of the $Component variable in the DOM hierarchy

should read something more like:

If the component you want to access is a direct descendant or a sibling of the $Component variable in the visualforce component hierarchy

$Component is a server side (page formula) concept is not DOM related directly - rather it is visualforce component id centric and it value is the client id (DOM id).

I'll see about getting the documentation corrected.






Message Edited by dchasman on 07-11-2008 12:29 PM
The KnightThe Knight
Hi,
     Thanks a lot it is working.