use of the getRow() function on a datatable deprecated ?

92 views
Skip to first unread message

Tristan Chapo

unread,
Jul 1, 2013, 11:04:15 PM7/1/13
to google-visua...@googlegroups.com
Hello Everyone,

I was trying to use the getRow() method : The function in question is here.
But when running my webpage I get "Uncaught TypeError: Object #<U> has no method 'getRow' ".

Has this function been deprecated ? If not, how can I make sure I can use it ?

Cheers



Tristan Chapo

unread,
Jul 1, 2013, 11:44:48 PM7/1/13
to google-visua...@googlegroups.com

Here is my code :

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
google.load('visualization', '1',{'packages': ['table']});

and then later on (both data and dataToAdd are DataTable()):

data.addRow(dataToAdd.getRow(0));   

asgallant

unread,
Jul 2, 2013, 1:10:39 PM7/2/13
to google-visua...@googlegroups.com
There is no DataTable#getRow method.  What is the ultimate goal you are trying to accomplish here?  Copying data from one DataTable to another is rarely the best way to approach a problem, so there might be a simpler solution waiting for you.

Tristan Pochat

unread,
Jul 2, 2013, 7:38:37 PM7/2/13
to google-visua...@googlegroups.com

Ah OK. So what is my link describing?
I found a workaround by using the ".K" property.

--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/m12BbSUmQc0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

asgallant

unread,
Jul 3, 2013, 12:19:22 PM7/3/13
to google-visua...@googlegroups.com
That looks like the Java API, not the JavaScript API.  Be careful using shortcuts like that - the internal workings of the API are subject to change at any time, so updates can break your code if you depend on them.


On Tuesday, July 2, 2013 7:38:37 PM UTC-4, Tristan Chapo wrote:

Ah OK. So what is my link describing?
I found a workaround by using the ".K" property.

On 3 Jul 2013 01:10, "asgallant" <drew_g...@abtassoc.com> wrote:
There is no DataTable#getRow method.  What is the ultimate goal you are trying to accomplish here?  Copying data from one DataTable to another is rarely the best way to approach a problem, so there might be a simpler solution waiting for you.

On Monday, July 1, 2013 11:44:48 PM UTC-4, Tristan Chapo wrote:

Here is my code :

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
google.load('visualization', '1',{'packages': ['table']});

and then later on (both data and dataToAdd are DataTable()):

data.addRow(dataToAdd.getRow(0));   

On Tuesday, July 2, 2013 11:04:15 AM UTC+8, Tristan Chapo wrote:
Hello Everyone,

I was trying to use the getRow() method : The function in question is here.
But when running my webpage I get "Uncaught TypeError: Object #<U> has no method 'getRow' ".

Has this function been deprecated ? If not, how can I make sure I can use it ?

Cheers



--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/m12BbSUmQc0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualization-api+unsub...@googlegroups.com.

Tristan Pochat

unread,
Jul 3, 2013, 9:05:07 PM7/3/13
to google-visua...@googlegroups.com
Agreed.
What would you recommend then ?

I send several asynchronous queries to the server (which sends me back one datatable per query) and add them to my summary table as they come back.
I know the line I want to extract in each query.



To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.

asgallant

unread,
Jul 4, 2013, 1:27:52 AM7/4/13
to google-visua...@googlegroups.com
Try this:

// rowIndex is the row index you want to pull data from - you can loop this if you need to pull multiple rows
var json = dataToAdd.toJSON();
data.addRow(json.rows[rowIndex].c);
json = null;


This exploits the structure of the JSON representation of the DataTable - which is part of the public face of the API, so you can count on it being stable.  If you are pulling these from an AJAX query, you can actually skip creating a DataTable object entirely and just pull the row directly from the JSON.
To unsubscribe from this group and all its topics, send an email to google-visualization-api+unsubscr...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.

Tristan Pochat

unread,
Jul 4, 2013, 1:31:00 AM7/4/13
to google-visua...@googlegroups.com
nice.
I'll give it a try.
Thank you very much.



To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.

Tristan Pochat

unread,
Jul 4, 2013, 5:40:44 AM7/4/13
to google-visua...@googlegroups.com
I think you need to have JSON.parse(dataToAdd.toJSON()instead of dataToAdd.toJSON() in order to be able to manipulate the object.

But that works perfectly. Thanks for the pointer.

asgallant

unread,
Jul 4, 2013, 1:03:42 PM7/4/13
to google-visua...@googlegroups.com
You're right - the #toJSON method returns it as a string (as is proper for JSON); I forgot that step.
Reply all
Reply to author
Forward
0 new messages