2
Calculator__c objCalculator  = [Select id, name, (select id,
fee_amount__c, cost_Amount__c, Type__c, from
Non_Labor_Cost_Details__r) From Calculator__c p where id =: PId];

When I try to use this object in Javascript like this:

{!objPricingCalculator.Non_Labor_Cost_Details__r}

It returns only list of Ids (comma separated). It's not returning fee_amount__c, cost_Amount__c and Type__c values.

Is there any way through which I can also extract fee_amount__c, cost_Amount__c and Type__c along with Id.

I don't want to use Javascript Remoting as I will have to change code flow for this.

0

1 Answer 1

2

//Apex class

 public class sample{

 public Account gethello(){

      Account acc=[Select Id,(Select id,Name from Contacts) from Account where Id =acc.id];
     return acc;

   }
}

Visualforce code with Javascript

<apex:page controller="sample">

<script>

<apex:repeat var="a" value="{!hello.Contacts}">
   alert('hello'+'{!a.Name}');
 </apex:repeat>

 </script>

 </apex:page>

This is the starting point.Now you can declare your own function in javascript something like this in script

function Contact(){
      /* Note the field names are case-sensitive! */
      this.Id = null; /* set a value here if you need to update or delete */
      this.Name = null;
  }

After this you can use push function of javascript to form an object array using some samples from below URL.

http://www.w3schools.com/jsref/jsref_push.asp

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .