You need to sign in to do that
Don't have an account?

Using different components on Visualforce
I am trying to use a different components in a VF page.At present,the component is made only on Account object.The requirement is to make it for other standard objects like Contacts,Leads etc.
How will this go ? Thanks in advance. James
=== Page ===
==== Component ===
How will this go ? Thanks in advance. James
=== Page ===
<apex:page standardController="Account"> <!-- This is for Account,how to do it for other objects ? --> <c:MadoleChartComponent /> </apex:page>
==== Component ===
<apex:component Controller="HighchartsController"> <script src="https://code.jquery.com/jquery-1.11.1.min.js"></script> <script src="https://code.highcharts.com/highcharts.js"></script> <script src="https://code.highcharts.com/modules/exporting.js"></script> <div id="container" style="min-width: 310px; height: 400px; margin:0 auto"></div> <script> pieOrdinate = {!X}; // pieOrdinate = ServerStr.split(','); $(function () { $('#container').highcharts({ title: { text: 'Chart showing opportunities' }, xAxis:{ categories: ['Jan','Feb','Mar','Apr','May','Jun','July','Aug','Sept','Oct','Nov','Dec'] }, labels: { items: [{ html: 'Opportunities', style: { left: '50px', top: '18px', color: (Highcharts.theme && Highcharts.theme.textColor) || 'black' } }] }, series: [ { type: 'column', name: 'Indian Railways', data: {!str} //data:[2,3,4,5,6] }, { type: 'spline', name: 'Monthly Sales', // Average // data: [3, 2.67, 3, 6.33, 3.33], data :{!bar}, marker: { lineWidth: 2, lineColor: Highcharts.getOptions().colors[3], fillColor: 'white' } }, { type: 'pie', name: 'Total consumption', data: [ { name: 'Lost', //y:23, y :parseInt(pieOrdinate[0]), sliced:true, selected:true, color: Highcharts.getOptions().colors[1] // Opp's Lost color }, { name: 'Won', y:parseInt(pieOrdinate[1]), color: Highcharts.getOptions().colors[2] // Opp's won color }], center: [100, 80], size: 100, showInLegend: false, dataLabels: { enabled:true } }] }); }); </script> </apex:component>
To generalize the component, you might add an attribute to take in a generic sobject. Or, you could pass in a controller or an abstract class / interface as an attribute.
I've tested the following component on my org, which takes the generic sobject and a field set to display the fields "dynamically" or in a more generic way.
Below is the Visualforce page that calls the component:
Hope that helps,
- Another James
Thanks again.