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
SimbaSimba 

How to pass DataTable from Google Visualization VF Page to Apex

I am using Google Visualization API to display the charts on the Visualforce page. By using GoogleViz I am creating a dataset to be used for the google chart (by passing the Jason String from Apex Controller to the VF page). Can I do something similar vice versa. Which is send data in the dataTable (of the chart) in the Jason String format, back to the Controller, which then I want to display on a different Visualforce Page as a report.

 

This will help me save a query for the report.

 

I appreciate any help in this.

 

Thanks

 

 

 

 

wesnoltewesnolte

Hey

 

It depends on what you acutally need to do.. How do you plan to get teh data initially?

 

I would pass the datatable from a page to a controller using an <apex:inputHidden> field personally, I'm not sure if this fits your requirements though.

 

Cheers,

Wes 

SimbaSimba

 

To begin with I pass the JSON String to the page from Apex and then I am using this Json String to display the Chart..

 

I am not sure how to pass the datatable to the Apex.

 

Besides that, even if I have the jsonString on the Apex side or DataTable, how can I use this Json String / DataTable to get the rows and columns values from the Json string in Apex. Are there any methods of the JSON object that I can use in the Apex ?

 

Thanks for the help..

 

 

wesnoltewesnolte

Hey

 

You would have to build your own class to parse the JSON string. But if you have the data and build the JSON string from that why do you want to parse the JSON string back into data that can be used by Apex. You have the data in the database in the first place, and fetching it twice won't make too much of a difference.

 

Cheers,

wes

SimbaSimba

Thanks for the response. I simply wanted to avoid the connecting to the database and also some manipulation that I have to do on the data. Which means I will be performing the manilupalation twice.

 

I thing writng my own class to read the JSON will be very time consuming. But that's a nice library to have.

 

Thanks again for the quick response. that was very helpful.